/* Snapshot of console UI styles.
   Keep this file independent from docs/V2/prototype/styles.css so prototype tweaks
   don't immediately affect the running console. */

:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #f0f5f1;
  --text: #1c2430;
  --muted: #5c6b76;
  --border: #dde8e0;
  --border-strong: #c5d9cc;
  --accent: #2f8f57;
  --accent-hover: #267347;
  --accent-soft: #e3f2e8;
  --accent-muted: #b8dcc6;
  --warn: #c27803;
  --bad: #c53b3b;
  --ok: #2f8f57;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 36, 48, 0.06);
  --shadow-card: 0 4px 20px rgba(28, 36, 48, 0.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --stage-width: 300px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC",
    "Microsoft YaHei", sans-serif;
  line-height: 1.45;
}

/* Remove underline for console interactive links */
.btn,
.btn:hover,
.btn:focus,
.btn:active,
.btn:visited,
.mini,
.mini:hover,
.mini:focus,
.mini:active,
.mini:visited,
.nav__item,
.nav__item:hover,
.nav__item:focus,
.nav__item:active,
.nav__item:visited,
.pipeline-tabs__item,
.pipeline-tabs__item:hover,
.pipeline-tabs__item:focus,
.pipeline-tabs__item:active,
.pipeline-tabs__item:visited {
  text-decoration: none;
}

/* Explicit underlined links (e.g. signal list name/id) */
.linkUnderline,
.linkUnderline:hover,
.linkUnderline:focus,
.linkUnderline:active,
.linkUnderline:visited {
  text-decoration: underline;
  text-underline-offset: 2px;
  color: var(--text);
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 8px 20px;
}

.sidebarToggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  position: absolute;
  top: 50%;
  right: -17px;
  transform: translate(0, -50%);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease, background 140ms ease, border-color 140ms ease;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  /* Only show the right half (match reference) */
  clip-path: inset(0 0 0 50%);
}

.sidebarToggle:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.sidebar:hover .sidebarToggle {
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, -50%);
}

.sidebarToggle::before {
  content: "";
  position: absolute;
  left: 75%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  background: currentColor;
  /* Use an SVG chevron so visual centering is consistent across fonts. */
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20fill%3D%27none%27%20stroke%3D%27%23000%27%20stroke-width%3D%272.8%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%20d%3D%27M14%206l-6%206%206%206%27/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: 16px 16px;
  mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20fill%3D%27none%27%20stroke%3D%27%23000%27%20stroke-width%3D%272.8%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%20d%3D%27M14%206l-6%206%206%206%27/%3E%3C/svg%3E");
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: 16px 16px;
}

/* Collapsed state: chevron points right (">") */
body.sidebar-collapsed .sidebarToggle::before {
  transform: translate(-50%, -50%) rotate(180deg);
}

.nav__icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.nav__item--active .nav__icon {
  color: var(--accent);
}

.nav__text {
  flex: 1;
  min-width: 0;
}

/* Collapsed sidebar */
body.sidebar-collapsed .sidebar {
  width: 72px;
  padding: 20px 10px;
}

body.sidebar-collapsed .brand {
  justify-content: center;
  padding: 4px 0 16px;
}

body.sidebar-collapsed .brand {
  flex-direction: column;
  gap: 10px;
}

body.sidebar-collapsed .brand__meta {
  display: none;
}

body.sidebar-collapsed .sidebarToggle {
  display: inline-flex;
}

body.sidebar-collapsed .nav {
  padding: 0;
}

body.sidebar-collapsed .nav__item {
  justify-content: center;
  padding: 12px 10px;
  gap: 0;
  position: relative;
}

body.sidebar-collapsed .nav__dot,
body.sidebar-collapsed .nav__text {
  display: none;
}

body.sidebar-collapsed .nav__item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

body.sidebar-collapsed .nav__item:hover::after {
  opacity: 1;
}

body.sidebar-collapsed .sidebar__footer {
  justify-content: center;
  padding: 12px 0 8px;
}

body.sidebar-collapsed .sidebar__footer .pill {
  display: none;
}

/* Collapsed sidebar: hide email, keep logout */
body.sidebar-collapsed .sidebarUser__email {
  display: none;
}

.brand__logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.brand__name {
  font-weight: 700;
  font-size: 15px;
}

.brand__sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 4px;
}

.nav__item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav__item:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.nav__item--active {
  background: var(--accent-soft);
  border-color: var(--accent-muted);
  color: var(--text);
}

.nav__dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--border-strong);
}

.nav__item--active .nav__dot {
  background: var(--accent);
}

.sidebar__footer {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 6px 8px;
}

.pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--accent-soft);
  color: var(--text);
}

.pill--ghost {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
}

/* ----- Toasts (bottom-right) ----- */
.toastContainer {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 1fr 32px;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(28, 36, 48, 0.18);
  color: var(--text);
  transform: translateY(8px);
  opacity: 0;
  transition: transform 160ms ease, opacity 160ms ease;
}

.toast--shown {
  transform: translateY(0);
  opacity: 1;
}

.toast--leaving {
  transform: translateY(8px);
  opacity: 0;
}

.toast__body {
  min-width: 0;
}

.toast__msg {
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast__close {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  font-size: 18px;
}

.toast__close:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.toast--success {
  border-left: 4px solid var(--ok);
}

.toast--error {
  border-left: 4px solid var(--bad);
  background: #fff7f7;
}

/* ----- Main ----- */
.main {
  flex: 1;
  min-width: 0;
  padding: 20px 24px 32px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 12px;
}

.h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  max-width: 640px;
}

.topbar__right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.btnIcon {
  display: inline-block;
  margin-right: 8px;
}

.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn--ghost:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn--danger {
  background: #fff5f5;
  color: var(--bad);
  border-color: #f0caca;
}

/* Pipeline editor tabs (云效风格) */
.pipeline-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.pipeline-tabs__item {
  padding: 10px 18px;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  text-decoration: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}

.pipeline-tabs__item:hover {
  color: var(--text);
  background: rgba(47, 143, 87, 0.06);
}

.pipeline-tabs__item--active {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.content {
  margin-top: 0;
}

.workspace {
  display: block;
  min-height: calc(100vh - 200px);
}

.workspace__canvas-wrap {
  width: 100%;
  min-width: 0;
}

/* Flow tab: lock page vertical scroll, keep scroll inside canvas */
body.flow-lock-page-y {
  overflow: hidden;
}

body.flow-lock-page-y .main {
  height: 100vh;
  overflow: hidden;
}

body.flow-lock-page-y .content {
  height: calc(100vh - 120px);
  overflow: hidden;
}

body.flow-lock-page-y #flowWorkspace,
body.flow-lock-page-y #flowWorkspace .workspace__canvas-wrap,
body.flow-lock-page-y #flowWorkspace .grid,
body.flow-lock-page-y #flowWorkspace .grid > .card,
body.flow-lock-page-y #flowWorkspace .grid > .card > .card__bd,
body.flow-lock-page-y #flowWorkspace .pipeline-scroll,
body.flow-lock-page-y #flowWorkspace .pipeline-canvas,
body.flow-lock-page-y #flowWorkspace .stage,
body.flow-lock-page-y #flowWorkspace .stage__body {
  height: 100%;
  min-height: 0;
}

body.flow-lock-page-y #flowWorkspace .grid > .card > .card__bd {
  display: flex;
  flex-direction: column;
}

body.flow-lock-page-y #flowWorkspace .pipeline-scroll {
  flex: 1 1 auto;
  height: auto;
}

/* 流程画布与右侧抽屉之间的视觉分割（抽屉打开时） */
body.drawer-open .workspace__canvas-wrap {
  border-right: 1px solid var(--border-strong);
}

body.drawer-open {
  overflow: hidden;
}

/* Flow tab layout relies on normal page scrollbars (macOS friendly). */

/* ----- Grid / Cards ----- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.span-12 {
  grid-column: span 12;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card--flush {
  box-shadow: var(--shadow);
}

.card__hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.card__title {
  font-weight: 650;
}

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

.card__bd {
  padding: 16px;
}

.card__bd--canvas {
  padding: 12px 16px 20px;
}

.canvas-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.pipeline-scroll {
  overflow-x: auto;
  padding-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  overflow-y: hidden;
}

/* Allow vertical scroll inside sources list (stage 1) */

.pipeline-canvas {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  min-width: max-content;
  min-height: 320px;
  padding: 8px 0 16px;
}

/* Stage column：固定宽度，超出横向滚动 */
.stage {
  flex: 0 0 var(--stage-width);
  width: var(--stage-width);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0 8px;
  border-right: 1px solid var(--border);
}

.pipeline-canvas > .stage:last-child {
  border-right: none;
}

.stage__head {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 0 4px 10px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 12px;
}

.stage__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Only the "data sources" stage needs its own vertical scrollbar when too tall. */
.stage__body--sources {
  overflow-y: auto;
  padding-right: 4px;
  min-height: 0;
  /* Avoid last item being visually clipped (status + hints + card shadow). */
  padding-bottom: 120px;
}

/* Connector between stages（固定窄列，不参与「阶段」均分） */
.stage-connector {
  flex: 0 0 40px;
  width: 40px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-height: 140px;
}

/* 横向连线（阶段之间） */
.stage-connector::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: linear-gradient(90deg, var(--border) 0%, var(--accent-muted) 50%, var(--border) 100%);
}

.connector-plus {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border-strong);
  padding: 0;
  outline: none;
  font: inherit;
  user-select: none;
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 18px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.connector-plus:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.connector-plus--static {
  pointer-events: none;
  cursor: default;
}

/* Pipeline node card */
.pnode {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0;
  box-shadow: var(--shadow);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.pnode:hover {
  border-color: var(--accent-muted);
  box-shadow: 0 4px 14px rgba(47, 143, 87, 0.1);
}

.pnode--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.pnode__body {
  padding: 4px 12px 10px;
  cursor: pointer;
  border-radius: 0 0 var(--radius) var(--radius);
  outline: none;
}

.pnode__body:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent-muted);
}

/* 节点顶部「添加」：默认隐藏，悬停 / 焦点在本节点内时显示 */
.pnode__toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 28px;
  padding: 6px 8px 0;
}

.pnode__add {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2px);
  transition: opacity 0.15s ease, visibility 0.15s ease, background 0.12s ease, border-color 0.12s ease;
}

.pnode:hover .pnode__add,
.pnode:focus-within .pnode__add {
  opacity: 1;
  visibility: visible;
}

.pnode__add:hover {
  background: var(--accent-soft);
  border-color: var(--accent-muted);
}

.pnode__row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.pnode__icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.pnode__title {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.35;
}

.pnode__meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.pnode__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.pnode__foot--statusMsg {
  justify-content: flex-start;
  gap: 10px;
}

.sourceStatusMsg {
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sourceStatusMsg--bad {
  color: var(--bad);
}

.sourceStatusMsg--ok {
  color: var(--ok);
}

.status-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.status-pill--ok {
  background: var(--accent-soft);
  color: var(--ok);
  border: 1px solid var(--accent-muted);
}

.status-pill--warn {
  background: #fff8e6;
  color: var(--warn);
  border: 1px solid #f5e0a8;
}

.status-pill--bad {
  background: #fff5f5;
  color: var(--bad);
  border: 1px solid #f0caca;
}

.status-pill--aborted {
  background: #fff5f5;
  color: var(--bad);
  border: 1px dashed #f0caca;
}

.pnode__time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.status-pill--running {
  background: #eef6ff;
  color: #1c5fa8;
  border: 1px solid #cfe4ff;
  position: relative;
  /* Leave space for spinner so text doesn't overlap. */
  padding-right: 22px;
}

.status-pill--running::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-radius: 999px;
  border: 2px solid rgba(28, 95, 168, 0.25);
  border-top-color: rgba(28, 95, 168, 0.98);
  box-sizing: border-box;
  animation: asdSpin 0.8s linear infinite;
}

.status-pill--idle {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ----- Drawer overlay ----- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgba(28, 36, 48, 0.14);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.drawer-backdrop--visible {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 300;
  width: min(420px, 100vw);
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: -12px 0 32px rgba(28, 36, 48, 0.08);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  pointer-events: none;
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.drawer--wide {
  width: min(640px, 100vw);
}

.drawer--open {
  transform: translateX(0);
  pointer-events: auto;
}

.drawer__hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer__title {
  font-weight: 700;
  font-size: 15px;
}

.drawer__sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.drawer__close {
  border: none;
  background: var(--surface-2);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.drawer__close:hover {
  color: var(--text);
  border: 1px solid var(--border);
}

.drawer__bd {
  padding: 14px 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.drawer-section {
  margin-bottom: 18px;
}

.drawer-section__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.subtabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.subtab {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--muted);
}

.subtab--active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.mini-table th,
.mini-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.checkbox{
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch__track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #d4ded8;
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background 120ms ease, border-color 120ms ease;
  flex: 0 0 auto;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(28, 36, 48, 0.16);
  transition: transform 120ms ease;
}

.switch input:checked + .switch__track {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch__track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch__track {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.btn[disabled],
.mini[disabled] {
  pointer-events: none;
  opacity: 0.6;
}

.btn--loading {
  position: relative;
}

.btn--loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #fff;
  display: inline-block;
  margin-left: 10px;
  animation: spin 0.75s linear infinite;
  vertical-align: -2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.mini-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.rule-row {
  display: grid;
  grid-template-columns: 1fr 120px 1fr 100px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

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

.select,
.input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  color: var(--text);
}

.textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  color: var(--text);
  font-family: var(--mono);
  resize: vertical;
  min-height: 84px;
  max-height: 40vh;
  overflow: auto;
}

.select:focus,
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.errorText {
  margin-top: 6px;
  font-size: 12px;
  color: var(--bad);
}

.inlineRow {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.inlineRow > * {
  flex: 1 1 0;
  min-width: 120px;
}

.inputReveal {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.inputReveal .input {
  flex: 1 1 auto;
}

.revealBtn {
  flex: 0 0 auto;
  width: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.revealBtn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.revealBtn:focus {
  outline: none;
}

.revealBtn:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-soft);
  border-color: var(--accent);
}

.help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.kv {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}

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

.kv .v {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

.hidden {
  display: none !important;
}

/* ----- Modal ----- */
.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 36, 48, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 72px 18px 18px;
  z-index: 50;
  overflow: auto;
}

.modal {
  width: min(1100px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
}

.modal__hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  font-weight: 700;
  font-size: 14px;
}

.modal__close {
  text-decoration: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.modal__close:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.modal__bd {
  padding: 14px 16px 16px;
  overflow: auto;
}

/* Form sections */
.formSection {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.formSection:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.formSection__title {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 700;
}

/* Collapse (details/summary) */
.collapse {
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.collapse__summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  list-style: none;
}

.collapse__summary::-webkit-details-marker {
  display: none;
}

.collapse__summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transform: translateY(-1px);
}

details[open].collapse > .collapse__summary::before {
  content: "▾";
}

.collapse__body {
  margin-top: 10px;
}

/* ----- List meta / pager ----- */
.listMeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.isDisabled {
  pointer-events: none;
  opacity: 0.5;
}

/* Pager bar (bottom): total | pager | page size */
.pagerBar {
  margin: 12px auto 0;
  width: min(860px, 100%);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 12px;
}

.pagerBar__left,
.pagerBar__mid,
.pagerBar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pagerBar__mid {
  justify-content: center;
  gap: 12px;
}

.pagerBar__pageSize {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagerBar__pageSize .select {
  width: 96px;
}

.pagerBar__left {
  justify-content: flex-start;
}

.pagerBar__right {
  justify-content: flex-end;
}

/* Tables (other views) */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: var(--surface-2);
}

.table tbody tr:hover {
  background: #fafcfb;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

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

.formGroup {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.spanAll {
  grid-column: 1 / -1;
}

.span2 {
  grid-column: span 2;
}

.label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-family: var(--mono);
}

.reqMark {
  color: var(--bad);
  margin-left: 4px;
  font-weight: 800;
}

.formGrid--single {
  grid-template-columns: 1fr !important;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.kpiRow {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.kpi {
  flex: 1;
  min-width: 160px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

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

.kpi__v {
  font-size: 20px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--accent);
}

.logBox {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.logBox__hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.logTitle {
  font-weight: 600;
}

.log {
  margin: 0;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  max-height: 240px;
  overflow: auto;
  background: #fff;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* ----- Run logs (GitHub Actions-like list) ----- */
.runToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.runToolbar__left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.runCount {
  font-weight: 700;
  font-size: 13px;
}

.runFilter {
  width: min(420px, 100%);
}

.runList {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.runItem {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

/* Guard against accidental overrides */
.runList .runItem {
  display: flex;
}

.runItem:last-child {
  border-bottom: 0;
}

.runStatusIcon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  flex: 0 0 auto;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.runStatusIcon--ok {
  background: #e8f5ee;
  border-color: #bfe5cd;
}

.runStatusIcon--bad {
  background: #fff1f3;
  border-color: #ffc2c8;
}

.runStatusIcon--running {
  background: #eef6ff;
  border-color: #cfe4ff;
}

.runStatusIcon__svg {
  width: 12px;
  height: 12px;
  display: block;
}

.runStatusIcon__svg--ok {
  color: #1f883d; /* GitHub green */
}

.runStatusIcon__svg--bad {
  color: #cf222e; /* GitHub red */
}

.runStatusIcon__spinner {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(9, 105, 218, 0.25);
  border-top-color: rgba(9, 105, 218, 0.95);
  box-sizing: border-box;
  animation: asdSpin 0.8s linear infinite;
}

.runStatusIcon__dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.7;
}

@keyframes asdSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Button loading spinner (blue) */
.btnSpin {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  /* Use white so it stays visible on the theme green button (and while disabled opacity is applied). */
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.98);
  box-sizing: border-box;
  animation: asdSpin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}

.sidebar__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebarUser {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebarUser__email {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebarUserMenuWrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.sidebarUserMenuBtn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: none;
  font-weight: 700;
  letter-spacing: 1px;
}

.sidebarUserMenuBtn:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.sidebarUserMenu {
  position: fixed;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(28, 36, 48, 0.14);
  border-radius: 14px;
  padding: 10px;
  display: none;
  z-index: 9999;
}

.sidebarUserMenu--open {
  display: block;
}

.sidebarUserMenu__email {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 8px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebarUserMenu__sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.sidebarUserMenu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 10px;
  color: var(--bad);
  text-decoration: none;
}

.sidebarUserMenu__itemIcon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebarUserMenu__itemIcon svg {
  display: block;
}

.sidebarUserMenu__item:hover {
  background: #fff7f7;
  border: 1px solid rgba(197, 59, 59, 0.25);
}

/* Position is computed in JS; no special-casing needed for collapsed state. */

/* Auth pages (no sidebar) */
.app--noSidebar .main {
  margin-left: 0;
  width: 100%;
}

.app--noSidebar .content {
  padding-top: 18px;
}

.authWrap {
  width: 100%;
  max-width: 520px;
  margin: 18px auto 0;
}

.runMain {
  flex: 1;
  min-width: 0;
}

.runTitleRow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.runTitle {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.runMeta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.runMeta .mono {
  font-size: 12px;
}

.runRight {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  margin-top: 2px;
}

.runTime {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-muted);
  color: var(--accent);
}

.chipRow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.chip__k {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.chip__v {
  font-family: var(--mono);
  font-size: 11px;
}

.chip--out {
  background: var(--accent-soft);
  border-color: var(--accent-muted);
}

.chip--in {
  background: #fff;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.mini {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
  cursor: pointer;
}

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

@media (max-width: 960px) {
  .sidebar {
    display: none;
  }

  .drawer {
    width: 100%;
  }

  body.drawer-open .workspace__canvas-wrap {
    border-right: none;
  }

  .formGrid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1180px) and (min-width: 961px) {
  .formGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

