/* Phase 4D: existing Automation V2 workspace, shared V3 theme and controls. */
.automations-view{--automation-line:var(--v3-border);--automation-panel:var(--v3-card);--automation-muted:var(--v3-muted);display:grid;gap:var(--v3-space-4);min-width:0}
.automations-view-header{display:flex;align-items:center;justify-content:space-between;gap:var(--v3-space-4)}
.automations-view-header h3{margin:4px 0;font-size:1.5rem;color:var(--v3-text)}
.automations-view-header p{margin:0;color:var(--v3-muted);font-size:.85rem}
.automations-view-header .management-create-button{width:auto;min-height:var(--v3-touch);padding:0 16px;border:0;border-radius:var(--v3-radius-sm);background:var(--v3-primary);color:var(--v3-primary-contrast);font-size:.85rem;white-space:nowrap}
.automations-workspace{display:grid;grid-template-columns:minmax(240px,270px) minmax(180px,210px) minmax(0,1fr);min-height:0;border:1px solid var(--v3-border);border-radius:var(--v3-radius-md);overflow:hidden;background:var(--v3-card);box-shadow:var(--v3-shadow)}
.automation-library,.automation-branches-panel,.automation-editor-panel{min-width:0;min-height:0}
.automation-library{display:grid;grid-template-rows:auto minmax(0,1fr);border-right:1px solid var(--v3-border);background:var(--v3-page)}
.automation-library-toolbar{display:grid;grid-template-columns:minmax(0,1fr) 90px;gap:8px;padding:12px;border-bottom:1px solid var(--v3-border)}
.automation-search{display:flex;align-items:center;gap:6px;min-width:0;padding:0 8px;border:1px solid var(--v3-border);border-radius:var(--v3-radius-sm);background:var(--v3-card);color:var(--v3-muted)}
.automation-search input,.automation-library-toolbar select{width:100%;min-width:0;min-height:44px;border:0;background:transparent;color:inherit;font-size:.8rem}
.automation-library-toolbar select{height:44px;border:1px solid var(--v3-border);border-radius:var(--v3-radius-sm);padding:0 5px;background:var(--v3-card);color:var(--v3-text)}
.automations-page-list{min-height:0;overflow:auto;padding:12px;display:grid;align-content:start;gap:12px}
.automation-library-row{display:grid;grid-template-columns:minmax(0,1fr) 48px;align-items:center;gap:4px;border:1px solid var(--v3-border);border-radius:var(--v3-radius-md);padding:8px;background:var(--v3-card);box-shadow:var(--v3-shadow)}
.automation-library-row:hover{border-color:var(--v3-primary)}
.automation-library-row.is-selected{border-color:var(--v3-primary);background:var(--v3-secondary)}
.automation-library-item{width:100%;min-height:90px;display:grid;grid-template-columns:32px minmax(0,1fr);align-items:start;gap:8px;border:0;border-radius:var(--v3-radius-sm);padding:4px;text-align:left;color:inherit;background:transparent;cursor:pointer}
.automation-library-icon,.automation-provider-mark{width:32px;height:32px;border-radius:var(--v3-radius-sm);display:grid;place-items:center;background:var(--v3-secondary);color:var(--v3-primary);font-size:1rem}
.automation-library-icon.is-provider{font-size:.65rem;font-weight:800}
.automation-library-copy{display:grid;gap:6px;min-width:0}
.automation-library-copy strong,.automation-library-copy small,.automation-library-copy span{white-space:normal;overflow-wrap:anywhere;line-height:1.45}
.automation-library-copy strong{font-size:.85rem}
.automation-library-copy small{font-size:.73rem;color:var(--v3-muted)}
.automation-status-badge{font-size:.7rem;color:var(--v3-muted)}
.automation-status-badge.is-active{color:var(--v3-success)}
.automation-status-dot{width:9px;height:9px;border-radius:50%;background:var(--v3-muted);justify-self:center}
.automation-status-dot.is-active{background:var(--v3-success)}
.automations-empty,.automation-panel-empty{display:grid;place-items:center;text-align:center;align-content:center;gap:8px;padding:24px;color:var(--v3-muted);min-height:180px;overflow-wrap:anywhere}
.automations-empty-icon,.automation-panel-empty>span{font-size:1.4rem;color:var(--v3-primary)}
.automations-empty p,.automation-panel-empty p{margin:0;font-size:.8rem;line-height:1.5}
.automation-branches-panel{display:grid;grid-template-rows:auto minmax(0,1fr);border-right:1px solid var(--v3-border);background:var(--v3-page)}
.automation-pane-header{min-height:72px;display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:8px;padding:12px;border-bottom:1px solid var(--v3-border)}
.automation-pane-header h3{margin:4px 0 0;font-size:1rem}
.automation-pane-kicker{font-size:.7rem;color:var(--v3-muted)}
.automation-icon-button,.automation-add-row,.automation-branch-rename{width:44px;height:44px;border:1px solid var(--v3-border);border-radius:var(--v3-radius-sm);background:var(--v3-card);color:var(--v3-primary);font-weight:800;cursor:pointer}
.automation-back{display:none;min-height:44px;min-width:44px;border:0;border-radius:var(--v3-radius-sm);background:transparent;color:var(--v3-primary);font-weight:800;cursor:pointer}
.automation-branch-list{overflow:auto;padding:12px;display:grid;align-content:start;gap:10px}
.automation-branch-row{display:grid;grid-template-columns:minmax(0,1fr) 44px;align-items:center;gap:4px}
.automation-branch-item{width:100%;min-height:72px;display:grid;grid-template-columns:24px minmax(0,1fr) auto;align-items:center;gap:6px;padding:8px;border:1px solid var(--v3-border);border-radius:var(--v3-radius-sm);background:var(--v3-card);color:var(--v3-text);text-align:left;cursor:pointer}
.automation-branch-item:hover,.automation-branch-item.is-selected{border-color:var(--v3-primary);background:var(--v3-secondary)}
.automation-branch-number{width:24px;height:24px;border-radius:6px;display:grid;place-items:center;background:var(--v3-secondary);color:var(--v3-primary);font-size:.75rem}
.automation-branch-item>span:nth-child(2){display:grid;gap:5px;min-width:0}
.automation-branch-item strong,.automation-branch-item small{overflow-wrap:anywhere;white-space:normal;line-height:1.4}
.automation-branch-item strong{font-size:.8rem}.automation-branch-item small{font-size:.7rem;color:var(--v3-muted)}
.automation-branch-chevron{color:var(--v3-primary)}
.automation-editor-panel{background:var(--v3-card);overflow:hidden}
.automation-editor{height:100%;min-height:0;display:flex;flex-direction:column}
.automation-editor-header{flex:0 0 auto;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:10px;padding:12px 16px;border-bottom:1px solid var(--v3-border);background:var(--v3-card)}
.automation-editor-title{display:grid;gap:4px;min-width:0}
.automation-editor-title textarea{resize:none;line-height:1.4;overflow-wrap:anywhere;width:100%;min-width:0;min-height:44px;border:1px solid var(--v3-border);border-radius:var(--v3-radius-sm);background:var(--v3-page);color:inherit;padding:8px;font-size:.95rem;font-weight:750}
.automation-enabled{display:flex;align-items:center;gap:6px;min-height:44px;padding:6px 8px;border:1px solid var(--v3-border);border-radius:var(--v3-radius-sm);font-size:.8rem}
.automation-enabled input{accent-color:var(--v3-primary);width:20px;height:20px}
.automation-legacy-notice{padding:10px 16px;background:var(--v3-secondary);color:var(--v3-muted);font-size:.75rem;line-height:1.5}
.automation-editor-scroll{flex:1 1 auto;min-height:0;overflow:auto;padding:16px;display:grid;align-content:start;gap:16px;background:var(--v3-page);overscroll-behavior:contain}
.automation-rule-section{display:grid;gap:12px;padding:12px;background:var(--v3-card);border:1px solid var(--v3-border);border-left:3px solid var(--v3-primary);border-radius:var(--v3-radius-md);min-width:0}
.automation-rule-section.is-condition{border-left-color:var(--v3-warning)}
.automation-rule-section.is-action{border-left-color:var(--v3-success)}
.automation-rule-heading{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:8px}
.automation-rule-heading>div{display:grid;gap:4px;min-width:0}
.automation-rule-heading strong{font-size:.85rem}.automation-rule-heading small{font-size:.72rem;color:var(--v3-muted);line-height:1.4}
.automation-rule-badge{padding:7px;border-radius:var(--v3-radius-sm);background:var(--v3-secondary);color:var(--v3-primary);font-size:.7rem;font-weight:850}
.is-condition .automation-rule-badge{color:var(--v3-warning)}.is-action .automation-rule-badge{color:var(--v3-success)}
.automation-editor .workflow-editor-row{grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) 44px;gap:8px;margin-bottom:8px;min-width:0}
.automation-editor .workflow-editor-trigger-v2{grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) 44px}
.automation-editor .workflow-editor-row input,.automation-editor .workflow-editor-row select,.automation-editor .workflow-action-parameters input{height:44px;min-width:0;width:100%;border:1px solid var(--v3-border);border-radius:var(--v3-radius-sm);font-size:.8rem;background:var(--v3-page);color:var(--v3-text);padding:8px}
.automation-editor .management-editor-icon{width:44px;height:44px;min-width:44px;border-radius:var(--v3-radius-sm)}
.automation-editor .workflow-editor-action{border:1px solid var(--v3-border);border-radius:var(--v3-radius-sm);background:var(--v3-page);margin-bottom:10px;padding:10px;min-width:0}
.automation-editor .workflow-action-parameters{grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:8px}
.automation-draft-status{flex:0 0 auto;margin:0;padding:8px 16px;color:var(--v3-muted);font-size:.72rem;line-height:1.4;border-top:1px solid var(--v3-border)}
.automation-editor-actions{flex:0 0 auto;display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px;padding:12px 16px;border-top:1px solid var(--v3-border);background:var(--v3-card)}
.automation-editor-actions button,.automation-provider-actions button{min-height:44px;padding:8px 12px;border-radius:var(--v3-radius-sm);font-size:.8rem;font-weight:700;cursor:pointer}
.automation-delete{margin-right:auto;border:0;background:transparent;color:var(--v3-error)}
.automation-delete-branch{border:0;background:transparent;color:var(--v3-warning)}
.automation-secondary{border:1px solid var(--v3-border);background:var(--v3-card);color:var(--v3-text)}
.automation-primary{border:0;background:var(--v3-primary);color:var(--v3-primary-contrast)}
.automation-provider-detail{height:100%;min-height:0;overflow:auto;display:grid;place-items:start;align-content:center;gap:12px;padding:24px;overflow-wrap:anywhere}
.automation-provider-detail h2{margin:0;font-size:1.25rem}.automation-provider-detail p{color:var(--v3-muted);line-height:1.5;font-size:.85rem}
.automation-provider-actions{display:flex;flex-wrap:wrap;gap:8px}
.automation-provider-actions button{border:1px solid var(--v3-border);background:var(--v3-card);color:var(--v3-text)}
.automation-provider-actions button:first-child{background:var(--v3-primary);color:var(--v3-primary-contrast)}
#automations-view :is(button,input,textarea,select):focus-visible{outline:3px solid var(--v3-primary);outline-offset:2px}
#automations-view :is(button,input,textarea,select):disabled,#management-editor[data-editor-type="workflow-routine"] :is(button,input,textarea,select):disabled{opacity:.6;cursor:default}
#app-view.app-shell.automation-layout-active{height:100dvh;min-height:0;overflow:hidden}
#app-view.app-shell.automation-layout-active .content{display:grid;grid-template-rows:minmax(0,1fr);min-height:0;overflow:hidden}
#app-view.app-shell.automation-layout-active .automations-view{min-height:0;grid-template-rows:auto minmax(0,1fr);overflow:hidden}
@media(max-width:1340px) and (min-width:701px){
 .automations-workspace{grid-template-columns:minmax(220px,260px) minmax(0,1fr);grid-template-rows:150px minmax(0,1fr)}
 .automation-library{grid-row:1/3}
 .automation-branches-panel{grid-column:2;grid-row:1;border-right:0;border-bottom:1px solid var(--v3-border)}
 .automation-editor-panel{grid-column:2;grid-row:2}
 .automation-branch-list{display:flex;gap:8px;padding:8px}
 .automation-branch-row{min-width:240px;max-width:300px}
 .automation-pane-header{min-height:60px;padding:8px 12px}
 .automation-editor .workflow-editor-trigger-v2{grid-template-columns:repeat(2,minmax(0,1fr)) 44px}
 .automation-editor .workflow-editor-trigger-v2 .management-editor-icon{grid-column:3;grid-row:1/3}
}
@media(max-width:900px) and (min-width:701px){
 .automations-workspace{grid-template-columns:minmax(180px,210px) minmax(0,1fr);grid-template-rows:150px minmax(0,1fr)}
 .automation-library-toolbar{grid-template-columns:1fr}
 .automation-library-row{grid-template-columns:minmax(0,1fr)}
 .automation-library-toggle{justify-self:end}
 .automation-library-item{grid-template-columns:1fr}
 .automation-editor-header{grid-template-columns:minmax(0,1fr) auto}
 .automation-editor .workflow-editor-row,.automation-editor .workflow-editor-trigger-v2{grid-template-columns:minmax(0,1fr) 44px}
 .automation-editor .workflow-editor-row :is(input,select){grid-column:1}
 .automation-editor .workflow-editor-row .management-editor-icon{grid-column:2;grid-row:1}
 .automation-rule-heading{grid-template-columns:minmax(0,1fr) auto}
 .automation-rule-badge{grid-column:1}.automation-rule-heading>div{grid-column:1}.automation-rule-heading button{grid-column:2;grid-row:1/3}
}
@media(max-width:700px){
 body:has(#app-view.app-shell.automation-layout-active){padding-bottom:0}
 #app-view.app-shell.automation-layout-active{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr)}
 #app-view.app-shell.automation-layout-active .content{padding-bottom:calc(var(--v3-mobile-nav-height) + env(safe-area-inset-bottom,0px))}
 .automations-view-header{align-items:start;gap:8px}.automations-view-header h3{font-size:1.3rem}.automations-view-header p{font-size:.75rem}
 .automations-view-header .management-create-button{padding:0 10px;font-size:.75rem}
 .automations-workspace{display:block}
 .automation-library,.automation-branches-panel,.automation-editor-panel{display:none;height:100%;border:0}
 .automations-workspace[data-mobile-pane="library"] .automation-library{display:grid}
 .automations-workspace[data-mobile-pane="branches"] .automation-branches-panel{display:grid}
 .automations-workspace[data-mobile-pane="editor"] .automation-editor-panel{display:block}
 .automation-back{display:inline-flex;align-items:center;justify-content:center}
 .automation-editor-header{grid-template-columns:44px minmax(0,1fr);gap:8px;padding:10px}
 .automation-enabled{grid-column:2;justify-self:start}
 .automation-editor-scroll{padding:10px}
 .automation-editor .workflow-editor-row,.automation-editor .workflow-editor-trigger-v2,.automation-editor .workflow-action-parameters{grid-template-columns:minmax(0,1fr)}
 .automation-editor .workflow-editor-row .management-editor-icon{justify-self:end}
 .automation-editor-actions{padding:8px;gap:6px}.automation-editor-actions button{font-size:.75rem;padding:8px}
 .automation-draft-status{padding:6px 10px;font-size:.7rem}
}

/* Keep local draft actions together and separate from destructive actions. */
.automation-destructive-actions{display:flex;flex-wrap:wrap;gap:6px;margin-right:auto}
.automation-primary-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px}
