/* Workflows page – n8n-style layout, app design (matches Train / Tasks) */

.workflows-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--light, #f7f7f4);
}
html[data-theme="dark"] .workflows-page {
    background: var(--primary-dark, #1a1a1a);
}

/* Top bar: back + title/breadcrumb + tabs + actions */
/* Workflows top bar — inherits .train-page-header via HTML, just add layout overrides */
.workflows-top-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 20px;
    padding: 10px 20px;
    background: transparent;
    border-bottom: none;
}
.workflows-top-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.workflows-breadcrumb {
    font-size: 0.875rem;
    color: var(--gray, #86868b);
}
.workflows-top-tabs {
    display: flex;
    gap: 4px;
}
.workflows-tab {
    padding: 8px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--gray);
    cursor: pointer;
}
.workflows-tab:hover {
    color: var(--dark);
    background: rgba(0,0,0,0.05);
}
html[data-theme="dark"] .workflows-tab:hover {
    color: var(--light);
    background: rgba(255,255,255,0.08);
}
.workflows-tab.active {
    color: var(--input-accent, #f09024);
    background: rgba(240, 144, 36, 0.12);
}
.workflows-top-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.workflow-select,
.workflow-name-input {
    padding: 8px 12px;
    font-size: 0.875rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--dark);
}
html[data-theme="dark"] .workflow-select,
html[data-theme="dark"] .workflow-name-input {
    background: var(--primary, #2d2d2d);
    border-color: rgba(255,255,255,0.12);
    color: var(--light);
}
.workflow-select { min-width: 160px; }
.workflow-name-input { width: 180px; }
.workflows-saved-badge {
    font-size: 0.75rem;
    color: var(--gray);
    padding: 4px 8px;
}
.btn-workflow {
    padding: 8px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    border: none;
}
.btn-workflow-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--dark);
}
html[data-theme="dark"] .btn-workflow-ghost {
    color: var(--light);
    border-color: rgba(255,255,255,0.2);
}
.btn-workflow-ghost:hover {
    background: rgba(0,0,0,0.05);
}
html[data-theme="dark"] .btn-workflow-ghost:hover {
    background: rgba(255,255,255,0.08);
}
.btn-workflow-run {
    background: linear-gradient(135deg, #ff9500 0%, #e68600 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 149, 0, 0.35);
}
.btn-workflow-run:hover {
    background: linear-gradient(135deg, #ffa726 0%, #ff9500 100%);
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.45);
}
.btn-workflow-danger { color: #d32f2f; }
html[data-theme="dark"] .btn-workflow-danger { color: #ef5350; }

/* In-app delete confirmation (no browser confirm) */
.workflow-confirm-modal {
    padding: 8px 0;
    min-width: 280px;
}
.workflow-confirm-text {
    margin: 0 0 20px 0;
    font-size: 1rem;
    line-height: 1.4;
    color: var(--dark);
}
html[data-theme="dark"] .workflow-confirm-text {
    color: var(--light);
}
.workflow-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}
.workflow-confirm-modal .btn-workflow-danger {
    background: #d32f2f;
    color: #fff;
    border: none;
}
.workflow-confirm-modal .btn-workflow-danger:hover {
    background: #b71c1c;
}
html[data-theme="dark"] .workflow-confirm-modal .btn-workflow-danger {
    background: #ef5350;
    color: #fff;
}
html[data-theme="dark"] .workflow-confirm-modal .btn-workflow-danger:hover {
    background: #e53935;
}

/* Editor: palette + canvas */
.workflows-editor-panel {
    display: flex;
    flex: 1;
    min-height: 320px;
    overflow: hidden;
}
.workflows-editor-panel.hidden {
    display: none !important;
}
/* Executions tab: history list (saved in DB per user) */
.workflows-executions-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 320px;
    overflow: hidden;
    padding: 16px 20px;
    background: var(--white);
}
.workflows-executions-panel.hidden {
    display: none !important;
}
html[data-theme="dark"] .workflows-executions-panel {
    background: var(--primary-dark);
}
.workflows-executions-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.workflows-executions-hint {
    font-size: 0.8125rem;
    color: var(--gray);
    margin: 0;
}
.workflows-executions-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.workflows-execution-card {
    padding: 12px 14px;
    background: var(--light, #f5f5f7);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.8125rem;
}
html[data-theme="dark"] .workflows-execution-card {
    background: var(--primary);
    border-color: rgba(255,255,255,0.08);
}
.workflows-execution-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 8px;
}
.workflows-execution-id {
    font-family: var(--platform-font-mono);
    font-size: 0.75rem;
    color: var(--gray);
}
.workflows-execution-time {
    color: var(--gray);
}
.workflows-execution-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.workflows-executions-empty,
.workflows-executions-loading {
    color: var(--gray);
    margin: 0;
    padding: 12px 0;
}
.workflows-palette {
    width: 220px;
    padding: 14px;
    background: var(--white);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
}
html[data-theme="dark"] .workflows-palette {
    background: var(--dark-light);
    border-right-color: rgba(255,255,255,0.08);
}
.workflows-palette-section { margin-bottom: 18px; }
.workflows-palette-title {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--gray);
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-left: 4px;
}
.workflows-palette-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin: 5px 0;
    font-size: 0.875rem;
    border-radius: 10px;
    cursor: grab;
    background: var(--light, #f5f5f7);
    border: 1px solid transparent;
}
html[data-theme="dark"] .workflows-palette-item {
    background: var(--primary);
    border-color: transparent;
}
.workflows-palette-item:hover {
    border-color: var(--input-accent);
    background: rgba(255, 149, 0, 0.08);
}
.workflows-palette-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    font-size: 0.75rem;
    opacity: 0.8;
    line-height: 1;
    vertical-align: middle;
}
.workflows-palette-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}
.workflows-palette-cat-icon {
    display: inline-flex;
    align-items: center;
    width: 16px;
    height: 16px;
    vertical-align: middle;
}
.workflows-palette-cat-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}
.node-label-icon {
    display: inline-flex;
    align-items: center;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 2px;
}
.node-label-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* Canvas with dot grid (n8n-style) */
.workflows-canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--light);
}
html[data-theme="dark"] .workflows-canvas-wrap {
    background: var(--primary-dark);
}
.workflows-canvas-inner {
    position: relative;
    width: 100%;
    height: 100%;
}
.workflow-zoom-panel {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.workflow-zoom-btn {
    width: 32px;
    height: 28px;
    padding: 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    color: var(--dark);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.workflow-zoom-btn:hover {
    background: var(--light);
}
html[data-theme="dark"] .workflow-zoom-btn {
    background: var(--dark-light);
    color: var(--light);
    border-color: rgba(255,255,255,0.12);
}
html[data-theme="dark"] .workflow-zoom-btn:hover {
    background: rgba(255,255,255,0.12);
}
.workflows-canvas-dots {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(circle, var(--gray) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.35;
    pointer-events: none;
}
.workflows-edges-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
}
.workflows-edges-svg line,
.workflows-edges-svg path {
    stroke: var(--gray);
    stroke-width: 2;
    opacity: 0.7;
    fill: none;
}
.workflows-edges-svg line.workflow-edge,
.workflows-edges-svg path.workflow-edge {
    stroke: #f97316;
    stroke-width: 2.5;
    opacity: 0.9;
    fill: none;
    pointer-events: stroke;
    cursor: pointer;
}
.workflows-edges-svg path.workflow-edge-hitarea {
    stroke: transparent;
    stroke-width: 16;
    fill: none;
    pointer-events: stroke;
    cursor: pointer;
}
.workflows-edges-svg path.workflow-edge:hover,
.workflows-edges-svg line.workflow-edge:hover {
    stroke: #ea580c;
    stroke-width: 3.5;
}
.workflows-edges-svg path.workflow-edge-highlighted {
    stroke: #2563eb;
    stroke-width: 3.5;
    opacity: 1;
}
html[data-theme="dark"] .workflows-edges-svg path.workflow-edge-highlighted {
    stroke: #60a5fa;
}
.workflows-edge-label {
    font-size: 11px;
    font-weight: 600;
    fill: #f97316;
    pointer-events: none;
    user-select: none;
}
.workflows-edge-label-bg {
    fill: var(--page, #fff);
    rx: 8;
    ry: 8;
    pointer-events: none;
}
html[data-theme="dark"] .workflows-edge-label-bg { fill: #1c1c1e; }
.workflow-edge-delete-btn {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ff3b30;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    border: none;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: auto;
}
.workflows-canvas-wrap:hover .workflow-edge-delete-btn { opacity: 0.7; }
.workflow-edge-delete-btn:hover { opacity: 1; transform: scale(1.2); }
html[data-theme="dark"] .workflows-edges-svg line.workflow-edge,
html[data-theme="dark"] .workflows-edges-svg path.workflow-edge {
    stroke: #f97316;
    opacity: 0.95;
}
html[data-theme="dark"] .workflows-edges-svg line:not(.workflow-edge),
html[data-theme="dark"] .workflows-edges-svg path:not(.workflow-edge) {
    stroke: rgba(255, 255, 255, 0.5);
}
.workflow-execution-dot {
    fill: #ff9500;
    stroke: #fff;
    stroke-width: 2;
    pointer-events: none;
    filter: drop-shadow(0 0 6px rgba(255, 149, 0, 0.8)) drop-shadow(0 0 12px rgba(255, 149, 0, 0.4));
}
.workflows-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Nodes – app card style */
.workflow-node {
    position: absolute;
    min-width: 170px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.8125rem;
    background: var(--white);
    border: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    cursor: grab;
    user-select: none;
}
html[data-theme="dark"] .workflow-node {
    background: var(--dark-light);
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}
.workflow-node.dragging { cursor: grabbing; opacity: 0.92; }
.workflow-node .node-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: -4px -6px 6px;
    padding: 4px 6px;
    border-radius: 8px 8px 0 0;
    cursor: grab;
    color: var(--gray);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    line-height: 1;
    user-select: none;
}
.workflow-node .node-drag-handle:hover {
    background: rgba(0,0,0,0.04);
    color: var(--dark);
}
html[data-theme="dark"] .workflow-node .node-drag-handle:hover {
    background: rgba(255,255,255,0.06);
    color: var(--light);
}
.workflow-node .node-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--gray);
    text-transform: uppercase;
    margin-bottom: 4px;
}
.workflow-node .node-title { font-weight: 600; color: var(--dark); cursor: text; min-height: 1.2em; }
html[data-theme="dark"] .workflow-node .node-title { color: var(--light); }
.workflow-node .node-title[contenteditable="true"],
.workflow-node .node-sub[contenteditable="true"] { outline: 1px solid var(--input-accent); border-radius: 4px; padding: 2px 4px; user-select: text; }
.workflow-node .node-sub {
    font-size: 0.75rem;
    color: var(--gray);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
    min-height: 1em;
}
.workflow-node .node-tool-select-wrap {
    margin: 6px 0 4px 0;
}
.workflow-node .node-tool-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--gray);
    margin-bottom: 4px;
}
.workflow-node .node-tool-select {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    color: var(--dark);
    cursor: pointer;
}
html[data-theme="dark"] .workflow-node .node-tool-select {
    background: var(--primary, #2d2d2d);
    border-color: rgba(255,255,255,0.2);
    color: var(--light);
}
.workflow-node .node-llm-settings {
    margin: 6px 0 4px 0;
}
.workflow-node .node-llm-settings .node-tool-label { margin-top: 6px; }
.workflow-node .node-llm-provider,
.workflow-node .node-llm-model {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    color: var(--dark);
    cursor: pointer;
    margin-bottom: 2px;
}
html[data-theme="dark"] .workflow-node .node-llm-provider,
html[data-theme="dark"] .workflow-node .node-llm-model {
    background: var(--primary, #2d2d2d);
    border-color: rgba(255,255,255,0.2);
    color: var(--light);
}
.workflow-node .node-trigger-settings { margin: 6px 0 4px 0; }
.workflow-node .node-trigger-settings .node-tool-label { margin-top: 6px; }
.workflow-node .node-trigger-input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    color: var(--dark);
    margin-bottom: 4px;
}
html[data-theme="dark"] .workflow-node .node-trigger-input {
    background: var(--primary, #2d2d2d);
    border-color: rgba(255,255,255,0.2);
    color: var(--light);
}
.workflow-node .node-trigger-settings select.node-trigger-cron-preset {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    color: var(--dark);
    cursor: pointer;
    margin-bottom: 4px;
}
html[data-theme="dark"] .workflow-node .node-trigger-settings select.node-trigger-cron-preset {
    background: var(--primary, #2d2d2d);
    border-color: rgba(255,255,255,0.2);
    color: var(--light);
}
.workflow-node .node-trigger-hint { font-size: 0.75rem; color: var(--gray); }
.workflow-node .node-control-settings { margin: 6px 0 4px 0; }
.workflow-node .node-control-settings .node-tool-label { margin-top: 6px; }
.workflow-node .node-control-check-wrap { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 0.8125rem; color: var(--dark); }
.workflow-node .node-control-check-wrap input[type="checkbox"] { cursor: pointer; }
html[data-theme="dark"] .workflow-node .node-control-check-wrap { color: var(--light); }
.workflow-node.node-trigger { border-left: 4px solid #8b5cf6; }
.workflow-node.node-agent { border-left: 4px solid #06b6d4; }
.workflow-node.node-mcp { border-left: 4px solid #22c55e; }
.workflow-node.node-integration { border-left: 4px solid #3b82f6; min-width: 220px; }
.workflow-node.node-integration .node-tool-select-wrap .node-tool-label { margin-top: 6px; }
.workflow-node.node-integration .node-tool-select-wrap .node-tool-label:first-child { margin-top: 0; }
.workflow-node.node-integration textarea.node-integration-param {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    font-size: 0.75rem;
    font-family: var(--platform-font-mono);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    color: var(--dark);
    margin-bottom: 4px;
    resize: vertical;
}
html[data-theme="dark"] .workflow-node.node-integration textarea.node-integration-param {
    background: var(--primary, #2d2d2d);
    border-color: rgba(255,255,255,0.2);
    color: var(--light);
}
.workflow-node.node-integration .node-integration-credential,
.workflow-node.node-integration .node-integration-credential-select {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px 6px 26px;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4'/%3E%3C/svg%3E") no-repeat 6px center;
    color: var(--dark);
    margin-bottom: 4px;
    appearance: auto;
    -webkit-appearance: menulist;
    cursor: pointer;
}
html[data-theme="dark"] .workflow-node.node-integration .node-integration-credential,
html[data-theme="dark"] .workflow-node.node-integration .node-integration-credential-select {
    background-color: var(--primary, #2d2d2d);
    border-color: rgba(255,255,255,0.2);
    color: var(--light);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4'/%3E%3C/svg%3E");
}
.workflow-node.node-integration .node-integration-manage-creds:hover {
    border-color: var(--input-accent, #FF9500);
}
/* Integration credential config modal */
.integration-config-overlay {
    position: fixed; inset: 0; z-index: 9000;
    background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; padding: 16px;
}
.integration-config-modal {
    background: var(--white, #fff); border-radius: 16px; width: 100%; max-width: 440px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25); overflow: hidden;
}
html[data-theme="dark"] .integration-config-modal { background: #1c1c1e; color: #f9fafb; }
.integration-config-header {
    display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid rgba(0,0,0,0.08);
}
html[data-theme="dark"] .integration-config-header { border-bottom-color: rgba(255,255,255,0.08); }
.integration-config-icon { display: flex; align-items: center; }
.integration-config-icon svg { width: 28px; height: 28px; }
.integration-config-title { flex: 1; font-size: 1.1rem; font-weight: 700; }
.integration-config-close {
    width: 30px; height: 30px; border-radius: 8px; border: none; background: rgba(0,0,0,0.06);
    font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; color: inherit;
}
html[data-theme="dark"] .integration-config-close { background: rgba(255,255,255,0.08); }
.integration-config-close:hover { background: rgba(0,0,0,0.12); }
html[data-theme="dark"] .integration-config-close:hover { background: rgba(255,255,255,0.15); }
.integration-config-body { padding: 16px 20px; }
.integration-config-section-label {
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--gray, #86868b); margin-bottom: 10px;
}
.integration-config-label {
    display: block; font-size: 0.8rem; font-weight: 500; margin: 10px 0 4px; color: var(--dark, #1d1d1f);
}
.integration-config-label:first-child { margin-top: 0; }
html[data-theme="dark"] .integration-config-label { color: #d1d5db; }
.integration-config-input {
    width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid rgba(0,0,0,0.12);
    font-size: 0.88rem; background: transparent; color: inherit; box-sizing: border-box;
}
.integration-config-input-wrap {
    display: flex; align-items: stretch; gap: 8px;
}
.integration-config-input-wrap .integration-config-input {
    flex: 1; min-width: 0;
}
.integration-config-reveal-btn {
    border: none; border-radius: 8px; padding: 0 12px; min-width: 58px;
    background: rgba(0,0,0,0.08); color: inherit; font-size: 0.78rem;
    font-weight: 700; cursor: pointer; align-items: center; justify-content: center;
}
html[data-theme="dark"] .integration-config-reveal-btn { background: rgba(255,255,255,0.12); }
.integration-config-has-saved {
    border-color: rgba(34,197,94,0.55);
}
.integration-config-input:focus { outline: none; border-color: var(--input-accent, #FF9500); }
.integration-config-cred-name-wrap { margin-bottom: 2px; }
.integration-config-cred-name-wrap select.integration-config-input {
    appearance: auto; -webkit-appearance: menulist; cursor: pointer;
}
html[data-theme="dark"] .integration-config-input { border-color: rgba(255,255,255,0.15); }
html[data-theme="dark"] .integration-config-has-saved { border-color: rgba(34,197,94,0.65); }
.integration-config-status {
    padding: 0 20px 8px; min-height: 24px; font-size: 0.82rem;
}
.integration-config-footer {
    display: flex; gap: 8px; padding: 12px 20px 18px; justify-content: flex-end;
}
.integration-config-btn {
    padding: 9px 18px; border-radius: 8px; border: none; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: opacity 0.15s;
}
.integration-config-btn:hover { opacity: 0.85; }
.integration-config-test-btn {
    background: rgba(0,0,0,0.06); color: var(--dark, #1d1d1f);
}
html[data-theme="dark"] .integration-config-test-btn { background: rgba(255,255,255,0.1); color: #f9fafb; }
.integration-config-save-btn {
    background: var(--input-accent, #FF9500); color: #fff;
}

.workflow-node.node-approval { border-left: 4px solid #f59e0b; }
.workflow-node.node-condition { border-left: 4px solid #ec4899; }
.workflow-node.node-flow { border-left: 4px solid #6366f1; min-width: 180px; }
.workflows-palette-item-compact {
    font-size: 0.78rem;
    padding: 6px 8px;
    gap: 6px;
}
.workflows-palette-hint {
    font-size: 0.75rem;
    color: var(--gray);
    padding: 6px 4px;
    line-height: 1.4;
}
.workflows-palette-subgroup {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    max-height: 160px;
    overflow-y: auto;
}

.node-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--input-accent);
    border: 2px solid var(--white);
    cursor: crosshair;
    z-index: 2;
}
html[data-theme="dark"] .node-handle { border-color: var(--dark-light); }
.node-handle.output { top: 50%; right: -6px; transform: translateY(-50%); }
.node-handle.input { top: 50%; left: -6px; transform: translateY(-50%); }
.node-handle.connecting { box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.6); }
.node-handle-drop-target { box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.8); background: rgba(6, 182, 212, 0.3); }
.workflow-node.node-selected { box-shadow: 0 0 0 2px var(--input-accent, #ff9500); }
.node-delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: rgba(0,0,0,0.08);
    color: var(--gray);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
}
.node-delete-btn:hover { background: #c62828; color: #fff; }
html[data-theme="dark"] .node-delete-btn { background: rgba(255,255,255,0.12); color: var(--light); }
html[data-theme="dark"] .node-delete-btn:hover { background: #ef5350; color: #fff; }
.workflows-canvas-wrap.workflow-connecting { outline: 2px dashed rgba(255, 149, 0, 0.4); outline-offset: -2px; }
.workflow-connect-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 14px;
    font-size: 0.75rem;
    color: var(--gray);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    z-index: 10;
    pointer-events: none;
}
html[data-theme="dark"] .workflow-connect-hint { background: var(--dark-light); border-color: rgba(255,255,255,0.12); }

/* Bottom panel: Run log */
.workflows-bottom-panel {
    border-top: 1px solid var(--border);
    background: var(--white);
}
html[data-theme="dark"] .workflows-bottom-panel {
    background: var(--dark-light);
    border-top-color: rgba(255,255,255,0.08);
}
.workflows-panel-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
}
.workflows-panel-toggle:hover { color: var(--dark); }
html[data-theme="dark"] .workflows-panel-toggle:hover { color: var(--light); }
.workflows-panel-toggle-icon { font-size: 0.7rem; transition: transform 0.2s; }
.workflows-bottom-panel.expanded .workflows-panel-toggle-icon { transform: rotate(-180deg); }
.workflows-run-log {
    padding: 12px 16px;
    max-height: 220px;
    overflow-y: auto;
    font-size: 0.8125rem;
    font-family: var(--platform-font-mono);
    line-height: 1.5;
    border-top: 1px solid var(--border);
}
.workflows-run-log.hidden { display: none !important; }
.workflows-bottom-panel.expanded .workflows-run-log { display: block; }
.workflows-run-log .log-ok { color: #2e7d32; }
html[data-theme="dark"] .workflows-run-log .log-ok { color: #66bb6a; }
.workflows-run-log .log-err { color: #c62828; }
html[data-theme="dark"] .workflows-run-log .log-err { color: #ef5350; }

/* Header bar: active state for Workflows button */
.chat-header-bar .btn-workflows-header.active,
.chat-header-bar .btn-tasks-header.active,
.chat-header-bar .btn-train-header.active {
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.5);
}

/* Workflows page: mobile – manageable layout, touch targets, safe areas */
@media (max-width: 768px) {
    .workflows-top-bar {
        padding: 12px max(16px, var(--sar)) 12px max(56px, var(--sal));
        padding-top: max(12px, var(--sat));
        gap: 10px 12px;
    }
    .workflows-top-left {
        flex: 1 1 100%;
        min-width: 0;
    }
    .workflows-page-title {
        font-size: 1.1rem;
    }
    .workflows-top-tabs {
        flex-shrink: 0;
    }
    .workflows-tab {
        min-height: 44px;
        padding: 10px 14px;
    }
    .workflows-top-actions {
        flex: 1 1 100%;
        margin-left: 0;
        gap: 8px;
    }
    .workflow-select {
        min-width: 0;
        flex: 1 1 140px;
    }
    .workflow-name-input {
        flex: 1 1 100%;
        min-width: 0;
        width: 100%;
    }
    .btn-workflow {
        min-height: 44px;
        padding: 10px 14px;
    }
    .workflows-editor-panel {
        flex-direction: column;
        min-height: 280px;
    }
    .workflows-palette {
        width: 100%;
        max-height: 160px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    html[data-theme="dark"] .workflows-palette {
        border-bottom-color: rgba(255,255,255,0.08);
    }
    .workflows-palette-section {
        margin-bottom: 0;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 8px;
    }
    .workflows-palette-title {
        width: 100%;
        margin-bottom: 4px;
        font-size: 0.65rem;
    }
    .workflows-palette-item {
        margin: 0;
        padding: 8px 12px;
        min-height: 44px;
        box-sizing: border-box;
    }
    .workflows-canvas-wrap {
        min-height: 240px;
    }
    .workflows-executions-panel {
        padding: 12px max(16px, var(--sar)) 12px max(16px, var(--sal));
        padding-bottom: max(12px, var(--sab));
    }
    .workflows-bottom-panel {
        padding-left: max(16px, var(--sal));
        padding-right: max(16px, var(--sar));
        padding-bottom: max(12px, var(--sab));
    }
}

/* Integrations palette: category subtitles + subgroups */
.workflows-palette-subtitle {
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--gray);
    margin: 10px 0 4px 4px;
    text-transform: uppercase;
}
.workflows-palette-subgroup {
    margin-bottom: 4px;
}

/* Compact category buttons in palette */
.integrations-search-wrap {
    padding: 4px 0 8px;
    position: relative;
}
.integrations-search-results {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
}
.integrations-search-results.hidden { display: none; }
.integrations-search-hit {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 7px 9px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    color: inherit;
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    text-align: left;
}
html[data-theme="dark"] .integrations-search-hit {
    background: var(--dark-light);
    border-color: rgba(255,255,255,0.1);
}
.integrations-search-hit:hover { border-color: var(--input-accent, #FF9500); }
.integrations-search-hit-name { font-weight: 600; }
.integrations-search-hit-meta { font-size: 0.68rem; color: var(--gray); }
.integrations-search-empty {
    font-size: 0.75rem;
    color: var(--gray);
    padding: 4px 2px;
}
.integrations-search-more {
    border: none;
    background: transparent;
    color: var(--input-accent, #FF9500);
    cursor: pointer;
    text-align: left;
    font: inherit;
    font-size: 0.75rem;
    padding: 6px 2px;
}
.integrations-search-input {
    width: 100%;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1.5px solid rgba(0,0,0,0.1);
    font-size: 0.8rem;
    background: transparent;
    color: inherit;
    box-sizing: border-box;
}
html[data-theme="dark"] .integrations-search-input {
    border-color: rgba(255,255,255,0.12);
}
.integrations-search-input:focus { outline: none; border-color: var(--input-accent); }

.workflows-palette-subsection {
    margin-bottom: 10px;
}
.workflows-palette-subtitle {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray);
    margin: 0 0 6px;
}
.workflow-integrations-used {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}
.workflow-integrations-used-empty {
    font-size: 0.75rem;
    color: var(--gray);
    line-height: 1.35;
    padding: 4px 0 6px;
}
.workflow-integration-used-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 7px 9px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    color: inherit;
    cursor: pointer;
    text-align: left;
    font: inherit;
}
html[data-theme="dark"] .workflow-integration-used-item {
    background: var(--dark-light);
    border-color: rgba(255,255,255,0.1);
}
.workflow-integration-used-item:hover {
    border-color: var(--input-accent, #FF9500);
}
.workflow-integration-used-name {
    font-size: 0.8125rem;
    font-weight: 600;
}
.workflow-integration-used-action,
.workflow-integration-used-links {
    font-size: 0.6875rem;
    color: var(--gray);
}

.integrations-category-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8125rem;
    transition: background 0.15s;
    color: inherit;
}
.integrations-category-btn:hover { background: rgba(0,0,0,0.05); }
html[data-theme="dark"] .integrations-category-btn:hover { background: rgba(255,255,255,0.06); }
.integrations-all-btn { font-weight: 600; margin-bottom: 4px; }
.integrations-cat-icon {
    font-size: 1rem;
    width: 20px;
    height: 20px;
    text-align: center;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.integrations-cat-icon svg { display: block; width: 18px; height: 18px; flex-shrink: 0; }
.integrations-cat-label { flex: 1; }
.integrations-cat-count {
    font-size: 0.7rem;
    background: rgba(0,0,0,0.08);
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
}
html[data-theme="dark"] .integrations-cat-count { background: rgba(255,255,255,0.1); }

/* Integration Store Modal */
.integration-store-overlay {
    position: fixed; inset: 0; z-index: 9000;
    background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; padding: 24px;
}
.integration-store-modal {
    background: var(--white, #fff); border-radius: 16px; width: 100%; max-width: 720px; max-height: 80vh;
    display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,0.3); overflow: hidden;
}
html[data-theme="dark"] .integration-store-modal { background: #1c1c1e; color: #f9fafb; }

.integration-store-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid rgba(0,0,0,0.08);
}
html[data-theme="dark"] .integration-store-header { border-bottom-color: rgba(255,255,255,0.08); }
.integration-store-title { font-size: 1.1rem; font-weight: 700; }
.integration-store-close {
    width: 30px; height: 30px; border-radius: 8px; border: none; background: rgba(0,0,0,0.06);
    font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; color: inherit;
}
html[data-theme="dark"] .integration-store-close { background: rgba(255,255,255,0.08); }

.integration-store-search { padding: 12px 20px 8px; }
.integration-store-search-input {
    width: 100%; padding: 9px 14px; border-radius: 10px;
    border: 1.5px solid rgba(0,0,0,0.1); font-size: 0.9rem;
    background: transparent; color: inherit; box-sizing: border-box;
}
html[data-theme="dark"] .integration-store-search-input { border-color: rgba(255,255,255,0.12); }
.integration-store-search-input:focus { outline: none; border-color: var(--input-accent); }

.integration-store-tabs {
    display: flex; gap: 4px; padding: 8px 20px; overflow-x: auto; flex-shrink: 0;
}
.integration-store-tab {
    padding: 5px 12px; border-radius: 20px; border: 1.5px solid rgba(0,0,0,0.1);
    background: transparent; font-size: 0.75rem; font-weight: 500; cursor: pointer;
    white-space: nowrap; color: inherit; transition: all 0.15s;
}
html[data-theme="dark"] .integration-store-tab { border-color: rgba(255,255,255,0.12); }
.integration-store-tab:hover { background: rgba(0,0,0,0.04); }
html[data-theme="dark"] .integration-store-tab:hover { background: rgba(255,255,255,0.06); }
.integration-store-tab.active { background: var(--input-accent); border-color: var(--input-accent); color: #fff; }
.integration-store-tab svg {
    display: inline-block;
    vertical-align: -3px;
    width: 14px;
    height: 14px;
    margin-right: 4px;
}
.tab-count { font-size: 0.65rem; opacity: 0.7; margin-left: 2px; }

.integration-store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}
.integration-store-group {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--white);
}
html[data-theme="dark"] .integration-store-group {
    background: var(--dark-light);
    border-color: rgba(255,255,255,0.1);
}
.integration-store-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.integration-store-config-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.7;
    padding: 4px;
}
.integration-store-actions {
    display: flex;
    flex-direction: column;
}
.integration-store-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 18px;
    font-size: 0.78rem;
    cursor: grab;
    border-top: 1px solid rgba(0,0,0,0.04);
}
html[data-theme="dark"] .integration-store-action {
    border-top-color: rgba(255,255,255,0.05);
}
.integration-store-action:hover {
    background: rgba(255,149,0,0.08);
}
.integration-store-action-label { font-weight: 500; }
.integration-store-action-hint { font-size: 0.68rem; color: var(--gray); }
.node-expression-hint {
    font-size: 0.68rem;
    color: var(--gray);
    margin-top: 6px;
    line-height: 1.35;
}
.workflow-node.node-condition .node-handle.output-true {
    top: 35%;
    right: -7px;
    background: #22c55e;
}
.workflow-node.node-condition .node-handle.output-false {
    top: 65%;
    right: -7px;
    background: #ef4444;
}
.workflow-node .node-handle.output {
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
}
.log-warn { color: #d97706; }
.workflow-approval-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px;
    padding: 12px 20px 20px; overflow-y: auto; flex: 1;
}
.integration-store-card {
    display: flex; align-items: center; gap: 10px;
    padding: 12px; border-radius: 10px; cursor: pointer;
    border: 1px solid rgba(0,0,0,0.06); transition: all 0.15s;
}
.integration-store-card:hover { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.12); }
html[data-theme="dark"] .integration-store-card { border-color: rgba(255,255,255,0.06); }
html[data-theme="dark"] .integration-store-card:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }
.integration-store-card-icon { width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.integration-store-card-icon svg { width: 32px; height: 32px; }
.integration-store-card-name { font-size: 0.85rem; font-weight: 600; }
.integration-store-card-desc { font-size: 0.7rem; opacity: 0.5; margin-top: 2px; }
.integration-store-empty { grid-column: 1/-1; text-align: center; padding: 40px; opacity: 0.4; font-size: 0.9rem; }

/* ---------------------------------------------------------------------------
   Agent Teams (Claude Teams–style)
--------------------------------------------------------------------------- */
.tasks-tab-bar { display: flex; gap: 2px; }
.tasks-tab {
    padding: 8px 14px; border-radius: 8px; border: none; cursor: pointer;
    background: transparent; color: var(--gray, #86868b); font-size: 0.875rem; font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.tasks-tab:hover { color: var(--dark, #1d1d1f); background: rgba(0,0,0,0.05); }
.tasks-tab.active { color: var(--input-accent, #ff9500); background: rgba(255, 149, 0, 0.12); }
html[data-theme="dark"] .tasks-tab { color: var(--gray, #86868b); }
html[data-theme="dark"] .tasks-tab:hover { color: var(--light, #f5f5f7); background: rgba(255,255,255,0.08); }
html[data-theme="dark"] .tasks-tab.active { color: var(--input-accent, #ff9500); background: rgba(255, 149, 0, 0.12); }

.agent-teams-panel {
    padding: 16px 20px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}
.agent-teams-top-bar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.agent-teams-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }

.agent-team-card {
    padding: 16px; border-radius: 10px; cursor: pointer;
    background: var(--white, #fff); border: 1px solid var(--border, rgba(0,0,0,0.08));
    transition: border-color 0.15s, box-shadow 0.15s;
}
.agent-team-card:hover { border-color: #f97316; box-shadow: 0 2px 8px rgba(249,115,22,0.12); }
html[data-theme="dark"] .agent-team-card { background: var(--dark-light, #2c2c2e); border-color: rgba(255,255,255,0.08); }
html[data-theme="dark"] .agent-team-card:hover { border-color: #fb923c; }

.agent-team-card-name { font-weight: 600; font-size: 1rem; margin-bottom: 6px; }
.agent-team-card-stats { font-size: 0.8rem; opacity: 0.6; }
.agent-team-card-stats span { margin-right: 10px; }
.agent-autonomous-card-subtitle {
    font-size: 0.72rem;
    opacity: 0.58;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.agent-autonomous-card-goal {
    font-size: 0.82rem;
    line-height: 1.45;
    opacity: 0.78;
    margin-top: 8px;
}

.agent-team-detail {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 400px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.agent-team-detail-header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 10px; border-bottom: 1px solid var(--border, rgba(0,0,0,0.08));
    flex-shrink: 0;
    min-width: 0;
}
.agent-team-detail-header > div { min-width: 0; }
.agent-team-detail-header h3 { overflow-wrap: anywhere; }
html[data-theme="dark"] .agent-team-detail-header { border-bottom-color: rgba(255,255,255,0.08); }

.agent-team-detail-nav {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.agent-team-detail-nav-btn {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(249, 115, 22, 0.18);
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 0.82rem;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.agent-team-detail-nav-btn:hover {
    border-color: rgba(249, 115, 22, 0.35);
    background: rgba(249, 115, 22, 0.06);
}
.agent-team-detail-nav-btn.active {
    border-color: rgba(249, 115, 22, 0.5);
    background: rgba(249, 115, 22, 0.14);
    color: #f59e0b;
    font-weight: 600;
}

.agent-team-detail-body {
    margin-top: 16px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 16px;
    min-width: 0;
    max-width: 100%;
}
.agent-team-detail-pane,
.agent-team-section {
    min-width: 0;
    max-width: 100%;
}
.agent-team-detail-pane.hidden {
    display: none !important;
}
.agent-team-section { margin-bottom: 20px; }
.agent-team-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.agent-team-section-header h4 { margin: 0; font-size: 0.9rem; font-weight: 600; }
.agent-team-autonomous-summary-card {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(249, 115, 22, 0.16);
    background: linear-gradient(180deg, rgba(249, 115, 22, 0.08), rgba(249, 115, 22, 0.03));
}
.agent-team-autonomy-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.agent-team-autonomy-summary-note {
    width: 100%;
    font-size: 0.8rem;
    opacity: 0.72;
    line-height: 1.45;
}

/* Schedule: stack like train forms (block labels + full-width fields; avoids inline label + input wrapping into uneven columns) */
.agent-team-schedule-hint {
    font-size: 0.8rem;
    margin: 0 0 10px;
    opacity: 0.85;
    line-height: 1.45;
}
.agent-team-schedule-enabled-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.agent-team-schedule-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.agent-team-schedule-fields.train-source-form {
    margin-top: 0;
}
.agent-team-schedule-fields.train-source-form .form-row:last-child {
    margin-bottom: 0;
}
.agent-team-schedule-fields input.form-input,
.agent-team-schedule-fields textarea.form-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    flex: none;
}
.agent-team-schedule-fields textarea.form-input {
    min-height: 80px;
    resize: vertical;
}
html[data-theme="dark"] .agent-team-schedule-fields.train-source-form label {
    color: var(--text-dark, #e5e5e7);
}

.agent-team-autonomy-hint {
    font-size: 0.8rem;
    margin: 0 0 12px;
    line-height: 1.45;
    opacity: 0.85;
}
.agent-team-autonomy-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.agent-team-autonomy-status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.agent-team-autonomy-activity {
    margin: 0 0 14px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(249, 115, 22, 0.16);
    background: rgba(249, 115, 22, 0.05);
}
.agent-team-autonomy-activity.hidden {
    display: none !important;
}
.agent-team-autonomy-activity-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 8px;
}
.agent-team-autonomy-activity-line {
    font-size: 0.84rem;
    line-height: 1.5;
    margin-bottom: 6px;
    word-break: break-word;
}
.agent-team-autonomy-activity-line:last-child {
    margin-bottom: 0;
}
.agent-team-autonomy-activity-list {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(249, 115, 22, 0.16);
}
.agent-team-autonomy-activity-list strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.agent-team-autonomy-activity-item {
    font-size: 0.82rem;
    line-height: 1.45;
    margin-bottom: 6px;
}
.agent-team-autonomy-activity-item:last-child {
    margin-bottom: 0;
}
.agent-team-autonomy-link-btn {
    margin-top: 8px;
}
.agent-team-autonomy-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.22);
    font-size: 0.78rem;
}
.agent-team-autonomy-pill strong {
    font-weight: 600;
}
.agent-team-autonomy-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}
.agent-team-autonomy-grid .form-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-width: 0;
    margin-bottom: 0;
}
.agent-team-autonomy-grid .form-row-full {
    grid-column: 1 / -1;
}
.agent-team-autonomy-grid .form-row label {
    display: block;
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--dark);
}
.agent-team-autonomy-field-hint {
    color: var(--gray, #8e8e93);
    font-size: 0.75rem;
    line-height: 1.35;
}
.agent-team-autonomy-grid textarea.form-input,
.agent-team-autonomy-grid input.form-input,
.agent-team-autonomy-grid select.form-input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.agent-team-autonomy-grid textarea.form-input {
    min-height: 96px;
    resize: vertical;
}
.agent-team-autonomy-toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 12px;
}
@media (max-width: 900px) {
    .agent-team-autonomy-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .agent-team-section-header {
        align-items: flex-start;
        gap: 8px;
        flex-wrap: wrap;
    }
    .agent-team-detail-nav {
        margin-top: 10px;
    }
}

html[data-theme="dark"] .agent-team-autonomy-grid .form-row label {
    color: var(--text-dark, #e5e5e7);
}

/* New task modal — cron subsection (same stacked rhythm as agent team schedule) */
.tasks-board-cron-block {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
}
.tasks-board-cron-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.tasks-board-cron-hint {
    font-size: 0.8rem;
    margin: 6px 0 10px;
    line-height: 1.45;
}
.tasks-board-cron-toggle-row {
    margin-bottom: 8px;
}
.tasks-board-cron-block > .form-row:last-child {
    margin-bottom: 0;
}

/* Teammates grid */
.agent-teammates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
    gap: 10px;
    min-width: 0;
    max-width: 100%;
}
.agent-teammate-card {
    position: relative;
    padding: 12px 14px 10px; border-radius: 10px;
    background: var(--light, #f5f5f7); border-left: 3px solid #f97316;
    font-size: 0.85rem;
    min-width: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}
html[data-theme="dark"] .agent-teammate-card { background: rgba(255,255,255,0.05); }
.agent-teammate-name { font-weight: 600; padding-right: 28px; }
.agent-teammate-role { opacity: 0.6; font-size: 0.8rem; }
.agent-teammate-status { margin-top: 4px; font-size: 0.75rem; }
.agent-teammate-status-idle { color: #6b7280; }
.agent-teammate-status-working { color: #f97316; }
.agent-teammate-status-planning { color: #8b5cf6; }
.agent-teammate-status-shutdown { color: #ef4444; }

/* Big visible delete X button on teammate cards */
.agent-teammate-delete-x {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    font-size: 16px;
    line-height: 1;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s ease;
    z-index: 2;
}
.agent-teammate-delete-x:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
    transform: scale(1.1);
}
html[data-theme="dark"] .agent-teammate-delete-x {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.5);
}

/* Task list in team */
.agent-team-tasks {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.agent-team-task {
    padding: 10px 12px; border-radius: 8px;
    background: var(--light, #f5f5f7); font-size: 0.85rem;
    display: flex; align-items: center; gap: 10px;
    min-width: 0;
}
html[data-theme="dark"] .agent-team-task { background: rgba(255,255,255,0.05); }
.agent-team-task-status {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.agent-team-task-status-pending { background: #6b7280; }
.agent-team-task-status-in_progress { background: #f97316; }
.agent-team-task-status-completed, .agent-team-task-status-done { background: #22c55e; }
.agent-team-task-status-failed { background: #ef4444; }
.agent-team-task-blocked { opacity: 0.5; }
.agent-team-task-title { font-weight: 500; flex: 1; min-width: 0; }
.agent-team-task-llm,
.agent-team-task-assignee { min-width: 0; overflow-wrap: anywhere; }
.agent-team-task-assignee { font-size: 0.75rem; opacity: 0.6; }
.agent-team-task-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.agent-team-task-actions button { font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.1); background: transparent; cursor: pointer; }
html[data-theme="dark"] .agent-team-task-actions button { border-color: rgba(255,255,255,0.1); color: var(--text-dark, #e5e5e7); }

/* Mailbox */
.agent-team-mailbox {
    max-height: 200px; overflow-y: auto; overflow-x: hidden; margin-bottom: 8px;
    display: flex; flex-direction: column; gap: 4px;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.agent-team-msg {
    padding: 6px 10px; border-radius: 6px; font-size: 0.82rem;
    background: var(--light, #f5f5f7);
    min-width: 0;
}
html[data-theme="dark"] .agent-team-msg { background: rgba(255,255,255,0.05); }
.agent-team-msg-from { font-weight: 600; color: #f97316; }
.agent-team-msg-to { opacity: 0.5; font-size: 0.75rem; }
.agent-team-paged-hint {
    padding: 6px 4px 2px;
    font-size: 0.72rem;
    opacity: 0.6;
    text-align: center;
}
.agent-team-msg-input {
    display: flex; gap: 8px;
    padding: 8px 0 0;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.agent-team-msg-input input {
    padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border, rgba(0,0,0,0.1));
    background: var(--white, #fff); color: var(--text, #1d1d1f); font-size: 0.85rem;
    flex: 1; outline: none; transition: border-color 0.2s;
}
.agent-team-msg-input input:focus {
    border-color: #f97316;
}
html[data-theme="dark"] .agent-team-msg-input input {
    background: var(--dark-light, #2c2c2e); border-color: rgba(255,255,255,0.1); color: var(--text-dark, #e5e5e7);
}
html[data-theme="dark"] .agent-team-msg-input input:focus {
    border-color: #f97316;
}

/* Sticky bottom bar — single row: [msg input] [Send] [task input] [Run] */
.agent-team-bottom-bar {
    flex-shrink: 0;
    padding: 10px 0 4px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 6px;
}
.agent-team-bottom-bar input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: var(--text-dark, #e5e5e7);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}
.agent-team-bottom-bar input:focus { border-color: #f97316; }
.agent-team-bottom-btn {
    flex-shrink: 0;
    min-width: 56px;
    padding: 9px 14px !important;
    font-size: 0.8rem !important;
    border-radius: 8px !important;
}

/* Run result */
.agent-team-run-result {
    margin-top: 10px; padding: 12px; border-radius: 8px;
    background: var(--light, #f5f5f7); font-size: 0.85rem;
    max-height: 400px; overflow-y: auto; overflow-x: hidden; white-space: pre-wrap;
    min-width: 0; max-width: 100%; box-sizing: border-box;
    overflow-wrap: anywhere; word-break: break-word;
}
html[data-theme="dark"] .agent-team-run-result { background: rgba(255,255,255,0.05); }

.agent-team-exec-history {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.agent-teams-empty {
    text-align: center; padding: 40px; opacity: 0.5; font-size: 0.9rem;
}
