/* AfkarOS form system — action-first, readable, consistent. */
html:has(dialog[open]),body:has(dialog[open]){overflow:hidden!important;overscroll-behavior:none!important}
#modal,.ux-dialog,#task-core-modal,#task-outcome-modal,#product-modal{border:0;border-radius:14px;box-shadow:0 24px 72px rgba(17,26,43,.22);overflow:hidden;background:#fff;overscroll-behavior:contain;touch-action:pan-y}
#modal,.ux-dialog,#task-core-modal,#task-outcome-modal,#product-modal{max-height:min(92dvh,calc(100dvh - 24px));margin:auto}
#modal{width:min(610px,calc(100vw - 28px));max-width:610px}
#modal-form,.ux-form,#task-core-form,#task-outcome-form,#product-form{display:flex;flex-direction:column;max-height:min(92dvh,calc(100dvh - 24px));min-height:0;background:#fff;overflow:hidden}
#modal-form>.modal-head,.ux-form>.modal-head,#task-core-form>.modal-head,#task-outcome-form>.modal-head,#product-form>.modal-head{padding:19px 22px 14px;border-bottom:1px solid #edf0f5;align-items:flex-start;flex:0 0 auto;background:#fff;z-index:3}
#modal-form>.modal-head h2,.ux-form>.modal-head h2,#task-core-form>.modal-head h2,#task-outcome-form>.modal-head h2,#product-form>.modal-head h2{font-size:21px;line-height:1.2;margin:4px 0 0}
.ux-subtitle{font-size:11.5px!important;line-height:1.45!important;color:var(--muted)!important;margin:6px 0 0!important}
/* Every normal modal gets one real scroll owner. This is critical on iOS/Safari so the page behind the dialog never receives the gesture. */
.ux-form-body,#modal-fields.ux-form-body{display:block!important;flex:1 1 auto!important;min-height:0!important;overflow-x:hidden!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;padding:18px 22px 20px!important;margin:0!important;touch-action:pan-y}
.ux-generic-modal #modal-fields{display:block!important}
/* Task is an older sibling-block form. Until it is structurally wrapped, the form itself owns scrolling and its chrome stays sticky. */
#task-core-form{overflow-x:hidden!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}
#task-core-form>.modal-head{position:sticky;top:0}
#task-core-form>.modal-actions{position:sticky;bottom:0;z-index:4}
#product-form{overflow-x:hidden!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}
#product-form>.modal-head{position:sticky;top:0}
#product-form>.modal-actions{position:sticky;bottom:0;z-index:4}
.ux-primary-grid{display:grid!important;grid-template-columns:1fr 1fr!important;gap:13px!important;min-width:0}
.ux-primary-grid>.field.full{grid-column:1/-1!important}
.field{display:flex;flex-direction:column;gap:6px;min-width:0}.field.full{grid-column:1/-1}
.field label{font-size:11px!important;line-height:1.3;font-weight:760!important;color:#556178!important;text-transform:none!important;letter-spacing:0!important}
.field input,.field select,.field textarea{width:100%;min-width:0;min-height:42px;border:1px solid #dfe3eb;border-radius:9px;background:#fff;color:var(--ink);padding:9px 11px;font-size:12px!important;line-height:1.4}
.field textarea{min-height:88px;resize:vertical}.field select[multiple]{min-height:118px;padding:7px}
.field input:focus,.field select:focus,.field textarea:focus{outline:0;border-color:#7c80f2!important;box-shadow:0 0 0 3px #6366f115!important}
.record-more{display:block!important;width:100%;margin:16px 0 0!important;border:1px solid #e3e6ee!important;border-radius:10px!important;background:#fafbfe!important;overflow:hidden}
.record-more>summary{list-style:none;cursor:pointer;padding:11px 13px!important;color:#59657a!important;font-size:11px!important;font-weight:800!important;line-height:1.35}.record-more>summary::-webkit-details-marker{display:none}.record-more>summary:after{content:'Optional';float:right;color:#8b94a6;font-weight:650}.record-more[open]>summary{border-bottom:1px solid #e3e6ee}.record-more[open]>summary:after{content:'Hide'}
.record-more .form-grid,.record-more-grid{display:grid!important;grid-template-columns:1fr 1fr!important;gap:12px!important;padding:13px!important;margin:0!important}.record-more-grid>.field.full{grid-column:1/-1!important}
.modal-actions,.ux-sticky-actions{display:flex!important;justify-content:flex-end!important;align-items:center!important;gap:7px!important;margin:0!important;padding:12px 22px!important;border-top:1px solid #e7eaf0!important;background:#fff!important;box-shadow:0 -6px 18px rgba(23,32,51,.035)!important;flex:0 0 auto}
.modal-actions .primary,.modal-actions .ghost{min-height:35px!important;padding:7px 12px!important;font-size:11.5px!important}.modal-actions .primary{min-width:94px!important}.modal-actions .danger-text{margin-right:auto}
.task-primary-fields{display:grid!important;grid-template-columns:1fr!important;gap:12px!important;padding:18px 22px 0!important}.task-context-details,.task-contact-context{margin-left:22px!important;margin-right:22px!important}.task-contact-context{margin-top:13px!important}.task-contact-context:empty{display:none}.task-contact-context>div{display:grid!important;gap:3px!important;padding:10px 12px!important;background:#f8f9fc;border:1px solid #e5e8ef;border-radius:9px;min-width:0}.task-contact-context .business-pill{width:max-content;margin-bottom:2px;padding:4px 7px!important}.task-contact-context b{display:block;font-size:12.5px!important;line-height:1.35;margin:0!important;overflow-wrap:anywhere}.task-contact-context small{display:block;color:var(--muted);font-size:10.5px!important;line-height:1.4!important;margin:0!important;overflow-wrap:anywhere}.task-context-details{margin-top:14px!important;border-top:1px solid #e7eaf0;padding-top:12px}.task-context-details>summary{list-style:none;cursor:pointer;color:#5f6a80;font-size:10.5px;font-weight:800;line-height:1.35;padding:4px 0}.task-context-details>summary::-webkit-details-marker{display:none}.task-context-details>summary:after{content:'Optional';float:right;color:#8b94a6;font-weight:650}.task-context-details[open]>summary:after{content:'Hide'}.task-context-details>.form-grid{display:grid;grid-template-columns:1fr;gap:11px;margin:11px 0 0;padding:0}.task-followup-box{margin:13px 22px 0!important;background:#f8f9fc!important;border:1px solid #e5e8ef!important;border-radius:9px!important;padding:12px!important}.task-followup-box p{font-size:11.5px!important;line-height:1.45;color:var(--muted)!important;margin:5px 0 0!important}.task-followup-toggle{display:flex!important;align-items:center;gap:9px;font-size:12px!important;font-weight:800;color:var(--ink);cursor:pointer}.task-followup-toggle input{width:16px!important;height:16px!important;margin:0!important;min-height:0!important}.task-followup-box #task-followup-fields[hidden]{display:none!important}.task-followup-box #task-followup-fields{display:grid;gap:11px;margin-top:13px;padding-top:13px;border-top:1px solid #e5e8ef}
/* In a task, the last conversation is the first memory to read. Pinned context and history follow underneath. */
.task-memory-wrap .memory-panel{display:flex!important;flex-direction:column!important}.task-memory-wrap .memory-head{order:0}.task-memory-wrap .memory-latest{order:1}.task-memory-wrap .memory-pinned{order:2;margin:8px 0 0!important}.task-memory-wrap .memory-history{order:3;margin-top:8px!important}
@media(max-width:680px){
 #modal,.ux-dialog,#task-core-modal,#task-outcome-modal,#product-modal{width:calc(100vw - 16px)!important;max-width:none!important;max-height:calc(100dvh - 18px)!important;margin:9px auto!important}
 #modal-form,.ux-form,#task-core-form,#task-outcome-form,#product-form{max-height:calc(100dvh - 18px)!important}
 .ux-primary-grid,.record-more .form-grid,.record-more-grid{grid-template-columns:1fr!important}.ux-primary-grid>.field.full,.record-more-grid>.field.full{grid-column:1!important}
 #modal-form>.modal-head,.ux-form>.modal-head,#task-core-form>.modal-head,#task-outcome-form>.modal-head,#product-form>.modal-head{padding:16px!important}
 .ux-form-body,#modal-fields.ux-form-body{padding:15px 16px 18px!important}
 .task-primary-fields{padding:15px 16px 0!important}.task-context-details,.task-contact-context,.task-followup-box{margin-left:16px!important;margin-right:16px!important}.modal-actions,.ux-sticky-actions{padding:11px 16px max(11px,env(safe-area-inset-bottom))!important}
}
