:root {
  --bg: #0c0f14;
  --surface: #141a22;
  --surface-2: #1a222c;
  --border: #2a3544;
  --text: #e8eef4;
  --muted: #8b9cb3;
  --accent: #d97706;
  --accent-dim: #92400e;
  --accent-soft: rgba(217, 119, 6, 0.15);
  --ok: #3d9a6a;
  --ok-soft: rgba(61, 154, 106, 0.15);
  --warn: #c98b2e;
  --fail: #c94f4f;
  --sidebar-w: 320px;
  --right-w: 340px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 0.65rem;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 15, 20, 0.95);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.brand { display: flex; gap: 0.75rem; align-items: center; min-width: 0; }
.brand h1 { margin: 0; font-size: 1.05rem; font-weight: 600; white-space: nowrap; }
.tagline { margin: 0; font-size: 0.75rem; color: var(--muted); }

.mark {
  width: 2.25rem; height: 2.25rem;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #111; font-weight: 700; border-radius: 0.45rem; flex-shrink: 0;
}

.topbar-center { flex: 1; text-align: center; min-width: 0; }
.project-title { font-weight: 600; font-size: 0.95rem; }

.topbar-right {
  display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; justify-content: flex-end;
}

.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-btn:hover { color: var(--text); }
.mode-btn.active { background: var(--accent-soft); color: var(--accent); }

.sys-status { font-size: 0.7rem; color: var(--muted); max-width: 200px; text-align: right; }

.status-pill {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.3rem 0.6rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
}
.status-pill.ok { border-color: var(--ok); color: var(--ok); }
.status-pill.warn { border-color: var(--warn); color: var(--warn); }

/* Shell */
.shell { flex: 1; min-height: 0; }
.shell.dashboard {
  display: grid;
  grid-template-columns: var(--sidebar-w) 5px 1fr 5px var(--right-w);
  overflow: hidden;
}

/* Welcome */
.welcome-hero {
  max-width: 640px;
  margin: 0 auto;
  padding: 4rem 1.5rem;
  text-align: center;
}
.welcome-hero h2 { margin: 0 0 0.75rem; font-size: 1.75rem; }
.welcome-hero .lead { color: var(--muted); margin-bottom: 1.5rem; }
.welcome-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-bottom: 2rem; }
.feature-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; text-align: left;
  font-size: 0.85rem; color: var(--muted);
}
.feature-grid strong { color: var(--text); display: block; margin-bottom: 0.15rem; }

/* Sidebars */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar.right {
  border-right: none;
  border-left: 1px solid var(--border);
}
.sidebar-resize-handle {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  touch-action: none;
  z-index: 2;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle:focus-visible {
  background: var(--accent-soft);
  outline: none;
}
.transcript-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.transcript-panel .console-section {
  flex-shrink: 0;
  max-height: 42%;
  overflow-y: auto;
}
.transcript-panel .messages-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.transcript-panel .message-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Explorer panel */
.explorer-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.explorer-section {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  min-height: 0;
}
.explorer-section-grow {
  flex: 1;
  min-height: 0;
  border-bottom: none;
}
.explorer-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.55rem 0.65rem;
  background: rgba(20, 26, 34, 0.55);
  flex-shrink: 0;
}
.explorer-section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.35rem 0.25rem;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s ease;
}
.explorer-section-toggle:hover { color: var(--text); }
.explorer-section-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 0.25rem;
}
.explorer-section.is-collapsed .explorer-chevron {
  transform: rotate(-90deg);
}
.explorer-chevron {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.explorer-badge {
  font-size: 0.65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.explorer-section-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.explorer-icon-btn {
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  padding: 0.3rem !important;
}
.explorer-section-body {
  padding: 0.55rem 0.65rem 0.75rem;
  min-height: 0;
}
.explorer-section.is-collapsed .explorer-section-body {
  display: none;
}
.explorer-section:not(.explorer-section-grow) .explorer-section-body {
  max-height: min(36dvh, 320px);
  overflow-y: auto;
}
.explorer-artifacts-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
  padding-top: 0.45rem;
}
.explorer-search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.15rem;
  flex-shrink: 0;
}
.explorer-search svg {
  flex-shrink: 0;
  color: var(--muted);
  opacity: 0.8;
}
.explorer-search input {
  flex: 1;
  min-width: 0;
  min-height: 2.25rem;
  font: inherit;
  font-size: 0.8rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
}
.explorer-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.explorer-tree-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(12, 15, 20, 0.35);
}
.explorer-tree-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.explorer-project-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.explorer-project-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem;
  align-items: stretch;
}
.explorer-project-row.is-pinned .project-item {
  border-color: rgba(217, 119, 6, 0.25);
}
.project-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  min-width: 0;
}
.project-item:hover { background: var(--surface-2); }
.project-item.active {
  background: var(--accent-soft);
  border-color: rgba(217, 119, 6, 0.35);
}
.project-item .project-title {
  display: block;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-item .pid {
  display: block;
  font-size: 0.66rem;
  color: var(--muted);
  margin-top: 0.12rem;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-pin-btn {
  display: grid;
  place-items: center;
  width: 2.25rem;
  min-height: 2.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}
.project-pin-btn:hover {
  color: var(--accent);
  background: var(--surface-2);
  border-color: var(--border);
}
.project-pin-btn.is-pinned {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(217, 119, 6, 0.35);
}
.project-pin-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.artifact-tree {
  font-family: var(--mono);
  font-size: 0.74rem;
  padding: 0.35rem 0;
  min-width: min-content;
}
.tree-folder {
  min-width: min-content;
}
.tree-folder-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  min-height: 2rem;
  padding: 0.3rem 0.55rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}
.tree-folder-toggle:hover {
  background: var(--surface-2);
  color: var(--accent);
}
.tree-folder-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.tree-folder.is-collapsed .tree-folder-chevron {
  transform: rotate(-90deg);
}
.tree-folder-chevron {
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform 0.15s ease;
}
.tree-folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-folder-count {
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.tree-folder-children {
  padding-left: 0.65rem;
  border-left: 1px solid rgba(42, 53, 68, 0.65);
  margin-left: 0.85rem;
}
.tree-folder.is-collapsed .tree-folder-children {
  display: none;
}
.tree-item {
  display: block;
  width: 100%;
  min-width: max-content;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  padding: 0.3rem 0.55rem;
  border-radius: 0.35rem;
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}
.tree-item:hover {
  color: var(--text);
  background: var(--surface-2);
}
.tree-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}
.tree-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.tree-item-label {
  display: block;
  white-space: nowrap;
  font-weight: 500;
}
.tree-item-path {
  display: block;
  font-size: 0.64rem;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0.85;
  margin-top: 0.08rem;
}
.artifact-tree-empty {
  padding: 1.25rem 0.75rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--font);
}

/* Workspace */
.workspace {
  overflow-y: auto;
  padding: 1rem 1.25rem;
  min-height: 0;
  background: radial-gradient(ellipse at 50% 0%, #151c26 0%, var(--bg) 60%);
}

.empty-state { color: var(--muted); text-align: center; padding: 3rem 1rem; }
.empty-state-actions { display: flex; gap: 0.65rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }
.empty-state.small { padding: 1.5rem; font-size: 0.9rem; }

.pipeline-board {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.pipeline-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem;
}
.pipeline-head h2 { margin: 0; font-size: 1rem; }
.pipeline-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.pipeline-action-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.pipeline-group-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-right: 0.15rem;
}
.pipeline-progress { margin-bottom: 0.75rem; }
.pipeline-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.pipeline-progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.pipeline-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ok), var(--accent));
  border-radius: 999px;
  width: 0%;
  transition: width 0.25s ease;
}
.pipeline-meta { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.75rem; }

.pipeline-steps {
  list-style: none; padding: 0; margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.step-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  background: var(--surface-2);
  font-size: 0.75rem;
}
.step-card.passed { border-color: var(--ok); background: var(--ok-soft); }
.step-card.running { border-color: var(--accent); background: var(--accent-soft); animation: pulse 1.2s ease infinite; }
.step-card.redoable { cursor: pointer; }
.step-card.redoable:hover,
.step-card.redoable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.step-card .step-label { font-weight: 600; display: block; margin-bottom: 0.2rem; }
.step-card .step-gate { color: var(--muted); font-size: 0.68rem; }
.step-card .step-job { font-size: 0.65rem; margin-top: 0.25rem; color: var(--muted); }
.step-card .step-redo { display: block; margin-top: 0.35rem; font-size: 0.68rem; color: var(--accent); font-weight: 600; }

@keyframes pulse { 50% { opacity: 0.75; } }

.gate-banners { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.gate-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.65rem 0.85rem; border-radius: var(--radius);
  background: var(--ok-soft); border: 1px solid var(--ok); font-size: 0.85rem;
}

/* Tabs */
.workspace-tabs {
  display: flex; gap: 0.25rem; margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.tab {
  border: none; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.85rem; padding: 0.55rem 1rem;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  min-height: 44px;
}
.tab:hover { color: var(--text); }
.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Editor */
.editor-toolbar {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.editor-path-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}
.editor-dirty-badge {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.editor-dirty-badge.saved { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.editor-dirty-badge.dirty { color: var(--warn); border-color: var(--warn); background: rgba(201, 139, 46, 0.15); }
.editor-path {
  font-family: var(--mono); font-size: 0.72rem; color: var(--muted);
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.version-select {
  font: inherit; font-size: 0.75rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 0.35rem;
  padding: 0.35rem 0.5rem; min-height: 36px;
}
.panel-title { margin: 0 0 0.5rem; font-size: 1rem; }
.panel-desc, .form-hint { margin: 0 0 0.75rem; font-size: 0.8rem; color: var(--muted); }
.settings-value { margin: 0 0 0.5rem; }
.settings-subtitle { margin: 0 0 0.5rem; font-size: 0.9rem; }
.settings-subform { margin-top: 0.75rem; }
.toolbar-spaced { margin-bottom: 0.75rem; }
.panel-spaced { margin-top: 1rem; }
.dialog-actions-start { justify-content: flex-start; }
.form-hint-break { word-break: break-all; }

.settings-shell {
  display: grid;
  grid-template-columns: minmax(120px, 160px) 1fr;
  gap: 1rem;
  align-items: start;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: sticky;
  top: 0;
}
.settings-nav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 44px;
}
.settings-nav-btn:hover { color: var(--text); background: var(--surface-2); }
.settings-nav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.settings-nav-btn.active {
  color: var(--accent);
  border-color: var(--border);
  background: var(--accent-soft);
}
.settings-panels { min-width: 0; }
.settings-panel[hidden] { display: none !important; }

.app-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: min(420px, 92vw);
  box-shadow: var(--shadow);
}
.app-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.app-dialog-form { padding: 1.25rem; margin: 0; }
.app-dialog-title { margin: 0 0 0.5rem; font-size: 1.05rem; }
.app-dialog-message { margin: 0 0 1rem; color: var(--muted); font-size: 0.9rem; }
.app-dialog-field { display: block; font-size: 0.8rem; margin-bottom: 0.35rem; color: var(--muted); }
.app-dialog-input {
  width: 100%;
  font: inherit;
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.5rem 0.65rem;
  margin-bottom: 1rem;
}
.btn.danger, #confirmDialogConfirm.danger {
  background: var(--fail);
  border-color: var(--fail);
  color: #fff;
}
.btn.is-loading { pointer-events: none; opacity: 0.75; }
.btn.is-loading::after {
  content: "";
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-left: 0.4em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -0.1em;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn, .project-item, .explorer-icon-btn, .project-pin-btn {
  min-height: 36px;
}
.btn.small { min-height: 32px; }

.artifact-editor {
  width: 100%; min-height: 360px; resize: vertical;
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.55;
  background: #0a0e12; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.artifact-editor:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.editor-hint { font-size: 0.75rem; color: var(--muted); margin: 0.5rem 0 0; }

/* Publish */
.publish-downloads {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem;
}
.download-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.75rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 0.8rem;
  transition: border-color 0.15s, background 0.15s;
}
.download-chip:hover { border-color: var(--accent); background: var(--accent-soft); }

.publish-preview {
  width: 100%; height: min(520px, 60vh);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff;
}

/* Delegate form */
.delegate-form {
  display: grid; gap: 0.75rem; max-width: 480px;
}
.delegate-form label { display: grid; gap: 0.3rem; font-size: 0.85rem; }
.delegate-form select, .delegate-form textarea, .delegate-form input[type="text"] {
  font: inherit; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.65rem;
}
.delegate-form input[type="number"] {
  font: inherit; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.65rem;
}
.checkbox { display: flex !important; align-items: center; gap: 0.5rem; }
.orch-fallback-set {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  display: grid;
  gap: 0.35rem;
}
.orch-fallback-set legend {
  padding: 0 0.35rem;
  font-size: 0.85rem;
}

/* Right panel */
.console-section, .messages-section { padding: 0.85rem; }
.console-section h2, .messages-section h2 {
  margin: 0 0 0.65rem; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  display: flex; align-items: center; gap: 0.4rem;
}

.live-pill {
  font-size: 0.6rem; padding: 0.15rem 0.4rem; border-radius: 999px;
  background: rgba(201, 79, 79, 0.2); color: #f08080;
  animation: pulse 1.2s ease infinite;
}

.agent-progress {
  margin-bottom: 0.65rem; padding: 0.65rem;
  background: rgba(0,0,0,0.25); border: 1px solid var(--border); border-radius: var(--radius);
}
.progress-header { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.4rem; font-size: 0.8rem; }
.spinner {
  width: 0.75rem; height: 0.75rem;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar { height: 3px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar-fill.indeterminate {
  width: 35%; height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  animation: indeterminate 1.4s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}
.console-latest { margin: 0.4rem 0 0; font-size: 0.72rem; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.agent-console {
  max-height: 200px; overflow-y: auto;
  padding: 0.65rem; background: #0a0e12;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--mono); font-size: 0.68rem; line-height: 1.45;
}
.agent-console .line { margin: 0.08rem 0; white-space: pre-wrap; word-break: break-word; }
.agent-console .line.stderr { color: #e8a87c; }
.agent-console .line.system { color: var(--muted); }
.agent-console .line.msg { color: #9fd4b0; }

.message-log { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.msg {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.5rem 0.65rem; font-size: 0.75rem;
}
.msg header { display: flex; justify-content: space-between; font-size: 0.65rem; color: var(--muted); margin-bottom: 0.25rem; }
.msg pre { margin: 0; white-space: pre-wrap; font-family: var(--mono); font-size: 0.68rem; max-height: 120px; overflow-y: auto; }
.msg.inbound { border-left: 3px solid var(--accent); }
.msg.outbound { border-left: 3px solid var(--ok); }

/* Buttons */
.btn {
  font: inherit; font-size: 0.85rem; font-weight: 500;
  padding: 0.45rem 0.85rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent-dim); color: #111; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { font-size: 0.75rem; padding: 0.3rem 0.6rem; }
.btn.large { padding: 0.65rem 1.25rem; font-size: 0.95rem; }
.btn.icon { width: 2rem; height: 2rem; padding: 0; font-size: 1.1rem; line-height: 1; }

.status { font-size: 0.65rem; padding: 0.15rem 0.4rem; border-radius: 999px; text-transform: uppercase; }
.status.running { background: var(--accent-soft); color: var(--accent); }
.status.succeeded { background: var(--ok-soft); color: var(--ok); }
.status.failed { background: rgba(201,79,79,0.2); color: var(--fail); }
.status.queued { background: rgba(139,156,179,0.15); color: var(--muted); }

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

/* Dialog */
dialog {
  border: 1px solid var(--border); border-radius: 1rem;
  background: var(--surface); color: var(--text);
  padding: 1.25rem 1.5rem; min-width: min(420px, 92vw);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0,0,0,0.65); }
dialog form { display: grid; gap: 0.75rem; }
dialog h3 { margin: 0; }
dialog label { display: grid; gap: 0.3rem; font-size: 0.85rem; }
dialog input, dialog select, dialog textarea {
  font: inherit; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

.admin-dialog.manage-dialog { min-width: min(800px, 96vw); }
.admin-shell.manage-shell { min-height: min(520px, 80dvh); }

.admin-form { display: grid; gap: 0.85rem; }
.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}
.admin-checkbox { margin-top: 0.15rem; }
.admin-subtitle {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.admin-required { color: var(--fail); }

.admin-token-status { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.5rem 0 0.75rem; }
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.admin-badge-ok { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.admin-badge-warn { border-color: var(--warn); color: var(--warn); background: rgba(201, 139, 46, 0.12); }
.admin-badge-muted { color: var(--muted); background: rgba(139, 156, 179, 0.1); }
.admin-badge-role { color: var(--accent); border-color: rgba(217, 119, 6, 0.35); background: var(--accent-soft); }

.admin-token-reveal {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(217, 119, 6, 0.4);
  border-radius: var(--radius);
  background: rgba(217, 119, 6, 0.08);
}
.admin-token-reveal-label {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
}
.admin-token-reveal-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.admin-token-value {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  word-break: break-all;
  padding: 0.55rem 0.65rem;
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.admin-users-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}
.admin-users-stats { margin-bottom: 0.85rem; }
.admin-users-stats.manage-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.admin-users-filter { margin-bottom: 0.85rem; }
.admin-users-filter input {
  width: 100%;
  min-height: 2.5rem;
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
}
.admin-users-filter input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.admin-create-user-form { margin-bottom: 0.85rem; }
.admin-users-list { display: flex; flex-direction: column; gap: 0.65rem; }

.admin-user-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition: border-color 0.15s ease, opacity 0.15s ease;
}
.admin-user-delete {
  grid-column: 1 / -1;
  margin-top: 0.35rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(201, 79, 79, 0.45);
  border-radius: var(--radius);
  background: rgba(201, 79, 79, 0.08);
}
.admin-user-delete-text {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}
.admin-user-card:hover { border-color: rgba(217, 119, 6, 0.35); }
.admin-user-card.is-disabled { opacity: 0.72; }
.admin-user-card.is-disabled:hover { border-color: var(--border); }
.admin-user-card.is-viewing { border-color: rgba(217, 119, 6, 0.55); box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.2); }
.admin-user-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  min-width: 0;
}
.admin-user-name {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
}
.admin-user-sub {
  margin: 0.15rem 0 0;
  font-size: 0.76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  align-items: flex-start;
}
.admin-user-limit {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.admin-user-limit input {
  width: 4.5rem;
  min-height: 2.25rem;
  font: inherit;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.3rem 0.45rem;
}
.admin-user-limit input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.admin-empty {
  text-align: center;
  padding: 2rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.admin-empty-icon {
  display: inline-flex;
  margin-bottom: 0.65rem;
  color: var(--muted);
  opacity: 0.7;
}
.admin-empty-title { margin: 0 0 0.35rem; font-size: 0.95rem; font-weight: 600; color: var(--text); }
.admin-empty-desc { margin: 0 0 1rem; font-size: 0.82rem; line-height: 1.5; }

.admin-view-banner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--warn);
  background: rgba(201, 139, 46, 0.12);
  font-size: 0.78rem;
}

@media (max-width: 720px) {
  .admin-dialog.manage-dialog { min-width: min(100vw - 1rem, 96vw); }
  .admin-users-header { flex-direction: column; align-items: stretch; }
  .admin-users-stats.manage-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-user-card { grid-template-columns: 1fr; }
  .admin-user-actions { justify-content: flex-start; }
}

.manage-dialog {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  min-width: min(760px, 96vw);
  max-width: 920px;
  max-height: min(88dvh, 720px);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.manage-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}
.manage-shell {
  display: flex;
  flex-direction: column;
  min-height: min(520px, 80dvh);
  max-height: min(88dvh, 720px);
}
.manage-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
}
.manage-eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 500;
}
.manage-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}
.manage-close-btn {
  flex-shrink: 0;
  border-color: transparent;
  color: var(--muted);
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.manage-close-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}
.manage-body {
  display: grid;
  grid-template-columns: 168px 1fr;
  flex: 1;
  min-height: 0;
}
.manage-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 0.65rem;
  border-right: 1px solid var(--border);
  background: rgba(20, 26, 34, 0.6);
}
.manage-nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.manage-nav-item svg { flex-shrink: 0; opacity: 0.85; }
.manage-nav-item:hover {
  color: var(--text);
  background: var(--surface-2);
}
.manage-nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.manage-nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(217, 119, 6, 0.35);
}
.manage-nav-item.manage-nav-danger.active {
  color: var(--fail);
  background: rgba(201, 79, 79, 0.12);
  border-color: rgba(201, 79, 79, 0.35);
}
.manage-nav-item.manage-nav-danger:hover:not(.active) {
  color: #e8a0a0;
}
.manage-content {
  padding: 1.1rem 1.25rem 1.25rem;
  overflow-y: auto;
  min-height: 0;
}
.manage-panel {
  display: none;
  flex-direction: column;
  gap: 1rem;
  animation: manage-panel-in 0.2s ease-out;
}
.manage-panel.active { display: flex; }
@keyframes manage-panel-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .manage-panel { animation: none; }
}
.manage-panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.manage-panel-desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}
.manage-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}
.manage-stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.manage-stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 500;
}
.manage-stat-value {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.manage-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 1rem;
}
.manage-profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(42, 53, 68, 0.6);
}
.manage-profile-field.manage-profile-field-full {
  grid-column: 1 / -1;
}
.manage-profile-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 500;
}
.manage-profile-value {
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}
.manage-profile-value.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
}
.manage-profile-value .status-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: capitalize;
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid rgba(61, 154, 106, 0.35);
}
.manage-path-card {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(26, 34, 44, 0.65);
}
.manage-path-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.manage-path-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 500;
}
.manage-path-value {
  display: block;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  word-break: break-all;
  color: var(--text);
  opacity: 0.9;
}
.manage-form-card,
.manage-danger-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 420px;
}
.manage-danger-card {
  max-width: 480px;
  padding: 1.1rem 1.15rem;
  border: 1px solid rgba(201, 79, 79, 0.4);
  border-radius: var(--radius);
  background: rgba(201, 79, 79, 0.06);
}
.manage-danger-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: 0.55rem;
  background: rgba(201, 79, 79, 0.15);
  color: var(--fail);
}
.manage-danger-text {
  margin: 0;
  font-size: 0.85rem;
  color: #e8b4b4;
  line-height: 1.55;
}
.manage-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.manage-field.compact { min-width: 0; }
.manage-field-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.manage-field-hint {
  font-size: 0.68rem;
  color: var(--muted);
  opacity: 0.85;
}
.manage-field input,
.manage-field select,
.manage-dialog select,
.manage-dialog input {
  min-height: 2.75rem;
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.manage-field input:focus,
.manage-field select:focus,
.manage-dialog select:focus,
.manage-dialog input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.manage-form-actions { display: flex; gap: 0.5rem; padding-top: 0.25rem; }
.manage-delete-btn { align-self: flex-start; min-height: 2.75rem; }
.manage-loading {
  display: grid;
  gap: 0.65rem;
}
.manage-skeleton {
  height: 3.25rem;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 25%, rgba(42, 53, 68, 0.5) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: manage-shimmer 1.2s ease-in-out infinite;
}
@keyframes manage-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .manage-skeleton { animation: none; background: var(--surface-2); }
}
@media (max-width: 720px) {
  .manage-dialog { min-width: min(100vw - 1rem, 96vw); }
  .manage-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .manage-nav {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem;
    gap: 0.35rem;
  }
  .manage-nav-item {
    flex: 1 0 auto;
    min-width: max-content;
    padding: 0.45rem 0.65rem;
  }
  .manage-nav-item span { white-space: nowrap; }
  .manage-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manage-profile-grid { grid-template-columns: 1fr; }
}

/* Activity monitor — wide-screen operations surface */
.activity-monitor-dialog {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  width: min(96vw, 1440px);
  max-width: 1440px;
  height: min(90dvh, 860px);
  max-height: 90dvh;
  overflow: hidden;
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.6);
}
.activity-monitor-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
}
.activity-monitor-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.activity-monitor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  flex-shrink: 0;
}
.activity-monitor-eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 500;
}
.activity-monitor-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}
.activity-monitor-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.activity-result-count {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.activity-close-btn {
  flex-shrink: 0;
  border-color: transparent;
  color: var(--muted);
}
.activity-close-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}
.activity-monitor-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  flex: 1;
  min-height: 0;
}
.activity-monitor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 1rem 1.25rem;
  border-right: 1px solid var(--border);
  background: rgba(20, 26, 34, 0.55);
  overflow-y: auto;
}
.activity-filter-block {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.activity-filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.activity-filter-hint {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.4;
}
.activity-monitor-sidebar input[type="search"],
.activity-monitor-sidebar input[type="date"],
.activity-monitor-sidebar select {
  min-height: 2.75rem;
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
  width: 100%;
}
.activity-monitor-sidebar input:focus,
.activity-monitor-sidebar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.activity-stage-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.activity-chip {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.activity-chip:hover {
  color: var(--text);
  border-color: var(--muted);
}
.activity-chip.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(217, 119, 6, 0.45);
}
.activity-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.activity-date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.activity-preset-btn {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.activity-preset-btn:hover { color: var(--text); }
.activity-preset-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(217, 119, 6, 0.45);
}
.activity-date-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.activity-date-inputs label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.68rem;
  color: var(--muted);
}
.activity-sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 0.5rem;
}
.activity-sidebar-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
}
.activity-monitor-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.activity-table-wrap {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  table-layout: fixed;
}
.activity-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
}
.activity-table th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.65rem 0.85rem;
  white-space: nowrap;
}
.activity-table th:nth-child(1) { width: 11rem; }
.activity-table th:nth-child(2) { width: 7rem; }
.activity-table th:nth-child(3) { width: 10rem; }
.activity-table th:nth-child(4) { width: 7.5rem; }
.activity-table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid rgba(42, 53, 68, 0.65);
  vertical-align: top;
  line-height: 1.45;
  word-break: break-word;
}
.activity-table tbody tr {
  transition: background 0.12s ease;
}
.activity-table tbody tr:hover {
  background: rgba(217, 119, 6, 0.04);
}
.activity-table tbody tr.activity-row-expanded {
  background: rgba(26, 34, 44, 0.85);
}
.activity-table-empty,
.activity-table-loading {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem !important;
  font-size: 0.88rem;
}
.activity-cell-time {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}
.activity-cell-kind {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.activity-kind-pill {
  display: inline-flex;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.activity-kind-pill[data-kind="job"] { border-color: rgba(61, 154, 106, 0.4); color: var(--ok); }
.activity-kind-pill[data-kind="message"] { border-color: rgba(107, 159, 212, 0.4); color: #8eb8e8; }
.activity-kind-pill[data-kind="project_event"] { border-color: rgba(217, 119, 6, 0.4); color: var(--accent); }
.activity-kind-pill[data-kind="run_note"] { border-color: rgba(201, 139, 46, 0.4); color: var(--warn); }
.activity-cell-stage {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
}
.activity-cell-backend {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.activity-cell-summary {
  color: var(--text);
}
.activity-row-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.activity-row-toggle svg {
  flex-shrink: 0;
  opacity: 0.5;
  transition: transform 0.15s ease;
}
.activity-row-expanded .activity-row-toggle svg {
  transform: rotate(90deg);
}
.activity-row-detail td {
  padding: 0 0.85rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.activity-row-detail pre {
  margin: 0;
  padding: 0.65rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted);
}
.pipeline-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
@media (max-width: 1024px) {
  .activity-monitor-dialog {
    width: 98vw;
    height: 92dvh;
  }
  .activity-monitor-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .activity-monitor-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 42dvh;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
  }
  .activity-filter-block { flex: 1 1 180px; min-width: 140px; }
  .activity-sidebar-actions {
    flex-direction: row;
    flex: 1 1 100%;
    margin-top: 0;
  }
  .activity-sidebar-actions .btn { flex: 1; }
}
@media (max-width: 720px) {
  .activity-table th:nth-child(4),
  .activity-table td:nth-child(4) { display: none; }
  .activity-date-inputs { grid-template-columns: 1fr; }
}
.btn.danger {
  background: rgba(201,79,79,0.25); color: var(--fail); border: 1px solid var(--fail);
}
.btn.danger:disabled { opacity: 0.45; cursor: not-allowed; }

.figure-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}
.figure-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  font-size: 0.75rem;
}
.figure-card img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: #0a0e12;
  display: block;
}
.figure-card .meta { padding: 0.5rem 0.65rem; }
.figure-card .meta strong { display: block; margin-bottom: 0.25rem; }
.figure-card .actions { display: flex; gap: 0.35rem; padding: 0 0.65rem 0.65rem; flex-wrap: wrap; }

.provider-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent, #d97706);
  vertical-align: middle;
}

.job-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.operator-alert {
  margin: 0.5rem 0;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid #a35d3a;
  background: #2a1810;
  color: #f0c9b0;
  font-size: 0.78rem;
}
.operator-alert strong { display: block; margin-bottom: 0.2rem; }
.status.paused, .status.blocked, .status.cancelled { color: #e8a87c; }
.status.failed { color: #f07178; }
.status.succeeded { color: #9fd4b0; }

.doctor-panel {
  margin-top: 0.85rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.doctor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.doctor-head h3 { margin: 0; font-size: 0.95rem; }
.doctor-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.doctor-overall {
  margin-left: 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.doctor-overall.ok { color: #9fd4b0; }
.doctor-overall.warn { color: #e8a87c; }
.doctor-overall.fail { color: #f07178; }
.doctor-findings { display: grid; gap: 0.45rem; }
.doctor-finding {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: start;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.78rem;
}
.doctor-finding .sev {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.65rem;
  padding-top: 0.15rem;
}
.doctor-finding .sev.ok { color: #9fd4b0; }
.doctor-finding .sev.warn { color: #e8a87c; }
.doctor-finding .sev.fail { color: #f07178; }
.doctor-finding strong { display: block; }
.doctor-finding .detail { color: var(--muted); margin-top: 0.15rem; }

.app.blurred { filter: blur(2px); pointer-events: none; user-select: none; }

.login-card {
  display: grid;
  gap: 0.75rem;
  width: min(420px, 92vw);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-card h2 { margin: 0; }
.login-card input {
  font: inherit; width: 100%; box-sizing: border-box;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0.55rem;
}

body.is-resizing-sidebar { cursor: col-resize; user-select: none; }

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 0.65rem 1.25rem; border-radius: 999px; font-size: 0.85rem;
  box-shadow: var(--shadow); z-index: 1000;
}

/* Responsive */
@media (max-width: 1100px) {
  .shell.dashboard {
    grid-template-columns: 220px 1fr;
    grid-template-rows: 1fr auto;
  }
  .sidebar-resize-handle { display: none; }
  .sidebar.left { grid-column: 1; grid-row: 1; }
  .workspace { grid-column: 2; grid-row: 1; }
  .sidebar.right {
    grid-column: 1 / -1;
    grid-row: 2;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 320px;
    flex-direction: row;
    overflow-x: auto;
  }
  .console-section, .messages-section { flex: 1; min-width: 280px; }
}

@media (max-width: 768px) {
  .shell.dashboard { grid-template-columns: 1fr; }
  .sidebar.left { max-height: min(42dvh, 360px); }
  .explorer-section:not(.explorer-section-grow) .explorer-section-body {
    max-height: 140px;
  }
  .feature-grid { grid-template-columns: 1fr; }
  .mode-toggle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
