.contract-template-chooser {margin:1rem 0;padding:1rem;border:1px solid var(--line,#bfd0c3);border-radius:1rem;background:#f8fbf5;}
.contract-template-chooser h3 {margin-top:0;}
.contract-template-controls {display:flex;flex-wrap:wrap;gap:.65rem;align-items:end;}
.contract-template-controls .field {flex:1 1 100%;min-width:0;}
.contract-template-controls .btn {white-space:normal;}
.contract-template-message {overflow-wrap:anywhere;}
.contract-template-message:empty {display:none;}
.contract-template-manager {width:min(58rem,calc(100vw - 2rem));max-height:calc(100dvh - 2rem);box-sizing:border-box;padding:1.25rem;border:1px solid #b5cdbb;border-radius:1rem;color:#203c32;background:#f7faf3;overflow-y:auto;}
.contract-template-manager::backdrop {background:#18382dc2;}
.contract-template-header {display:flex;flex-wrap:wrap;align-items:start;justify-content:space-between;gap:.75rem;}
.contract-template-header h2 {margin:.25rem 0;max-width:100%;overflow-wrap:anywhere;}
.contract-template-list {margin-bottom:1rem;}
.contract-template-row {padding:1rem 0;border-bottom:1px solid #d1dfd3;overflow-wrap:anywhere;}
.contract-template-row p {margin:.35rem 0 .65rem;}
.contract-template-editor {padding:1rem;border:1px solid #bfd0c3;border-radius:1rem;background:white;}
.contract-template-editor .contract-task-nav {margin:1rem 0;}
.contract-template-editor .contract-rule-sources {grid-column:1 / -1;}
.contract-template-editor .form-grid > .contract-field-hint {grid-column:1 / -1;}
.contract-template-editor input,.contract-template-editor select,.contract-template-editor textarea {min-width:0;max-width:100%;box-sizing:border-box;}
.contract-template-editor .setup-help-field {min-width:0;}
.contract-template-manager [hidden] {display:none!important;}
@media(max-width:520px){
 .contract-template-manager {width:calc(100vw - 1rem);max-height:calc(100dvh - 1rem);padding:.8rem;}
 .contract-template-editor {padding:.75rem;}
 .contract-template-manager .form-grid {grid-template-columns:minmax(0,1fr);}
 .contract-template-header h2 {font-size:1.5rem;}
 .contract-template-manager .actions {gap:.5rem;}
 .contract-template-manager .actions .btn {max-width:100%;white-space:normal;}
 .contract-template-editor .contract-task-nav button:last-child {grid-column:1 / -1;}
}
