body{background:#f5f6f8;color:#212529}.brand{font-size:1.45rem;font-weight:700}.work-table th{font-size:.78rem;text-transform:uppercase;color:#6c757d;white-space:nowrap}.work-table td{height:58px}.work-row{cursor:default}.expand-btn{width:30px;height:30px;padding:0;display:inline-flex;align-items:center;justify-content:center;border:1px solid #e1e5ea;background:#fff;color:#64748b;border-radius:8px;transition:background .15s,border-color .15s}.expand-btn:hover{background:#eef4ff;border-color:#b6ccf5;color:#0d6efd}.expand-chevron{width:7px;height:7px;border-right:1.8px solid currentColor;border-bottom:1.8px solid currentColor;transform:rotate(-45deg);transition:transform .15s;margin-left:-3px}.expand-btn[aria-expanded="true"] .expand-chevron{transform:rotate(45deg);margin-top:-4px}.type-badge{display:inline-flex;align-items:center;gap:.45rem;font-size:.82rem;font-weight:600;white-space:nowrap}.type-badge:before{content:"";width:8px;height:8px;border-radius:3px;display:inline-block}.type-badge.order{color:#0d6efd}.type-badge.order:before{background:#0d6efd}.type-badge.task{color:#198754}.type-badge.task:before{background:#198754}.status-select{min-width:115px}.detail-row{background:#f8f9fa}.detail-panel{padding:22px 30px 24px;border-top:1px solid #e9ecef}.detail-title{font-size:.75rem;font-weight:700;letter-spacing:.08em;color:#6c757d;margin-bottom:12px}.task-content{max-width:850px;font-size:1rem;line-height:1.55;background:#fff;border:1px solid #e9ecef;border-radius:8px;padding:14px 16px}.detail-panel .table{max-width:1000px}.detail-panel .table th{font-size:.78rem;color:#6c757d}.card{border-radius:12px}.work-table tbody tr.detail-row:hover{background:#f8f9fa}
.entity-suggestions{display:none;position:absolute;left:0;right:0;top:100%;z-index:1000;background:#fff;border:1px solid #dee2e6;border-radius:0 0 .375rem .375rem;box-shadow:0 .25rem .75rem rgba(0,0,0,.08);overflow:hidden}
.entity-option{display:block;width:100%;padding:.45rem .65rem;border:0;background:#fff;text-align:left;cursor:pointer}
.entity-option:hover{background:#f1f3f5}

.new-record-table{width:100%;table-layout:fixed;border-collapse:separate;border-spacing:0}
.new-record-table td{padding:0 .25rem;vertical-align:middle}
.new-record-table td:first-child{padding-left:0}
.new-record-table td:last-child{padding-right:0}
.new-record-table .form-control,.new-record-table .form-select{width:100%;min-width:0}
.new-record-submit{white-space:nowrap;width:100%;padding-left:.8rem;padding-right:.8rem}
@media(max-width:767.98px){.new-record-table,.new-record-table tbody,.new-record-table tr,.new-record-table td{display:block;width:100%}.new-record-table td{padding:.25rem 0}.new-record-table colgroup{display:none}}

.editable-cell{position:relative;cursor:pointer;transition:color .12s ease}
.editable-cell:hover{color:#0d6efd}
.editable-cell:hover .editable-value{text-decoration:underline;text-decoration-color:#b6d4fe;text-underline-offset:3px}
.editable-cell::after{content:"\270e";display:inline-block;margin-left:.45rem;color:#9aa2ab;font-size:.78rem;opacity:0;transition:opacity .12s ease}
.editable-cell:hover::after{opacity:1}
.editable-cell.is-editing::after{display:none}
.inline-editor-wrap{position:relative;min-width:110px}
.inline-editor{min-width:100%;width:100%}
.inline-suggestions{top:100%;left:0;right:0}
.inline-error{font-size:.75rem;color:#dc3545;white-space:normal}
.editable-cell.edit-error .inline-editor{border-color:#dc3545}
@media(hover:none){.editable-cell::after{opacity:1}.editable-cell:hover .editable-value{text-decoration:none}}

.detail-items-table{min-width:760px}
.detail-items-table input{min-width:70px}
.detail-items-table td{vertical-align:top}
.detail-items-table .detail-item-save,.detail-items-table .detail-item-delete-toggle{white-space:nowrap}
.detail-add-form{max-width:1000px}
.task-content-editor{max-width:1000px;line-height:1.55;resize:vertical}
.detail-action-error:empty{display:none}
@media(max-width:767.98px){.detail-panel{padding:16px 12px}.detail-items-table{min-width:700px}.detail-panel .d-flex.gap-2{gap:.4rem!important}}

.detail-item-actions{white-space:nowrap;width:1%}.detail-item-buttons{display:flex;justify-content:flex-end;gap:.35rem;white-space:nowrap}.detail-item-buttons .btn{flex:0 0 auto}

/* Compact spreadsheet-like order editor */
.detail-panel{padding:14px 20px 16px}
.detail-title{font-size:.9rem;font-weight:700;margin-bottom:10px;color:#59636e}
.detail-items-table{width:100%;min-width:0!important;margin-bottom:8px!important;font-size:.82rem;border-collapse:collapse}
.detail-items-table thead th{font-size:.82rem!important;font-weight:700;padding:.35rem .45rem;border-bottom:1px solid #dee2e6;white-space:nowrap}
.detail-items-table tbody td{padding:.22rem .3rem;vertical-align:middle;border-bottom:1px solid #e4e8ec}
.detail-items-table tfoot th{font-size:.9rem!important;font-weight:700;padding:.45rem .3rem;border-top:1px solid #d9dee4}
.detail-inline-input{display:block;width:100%;min-width:0;border:1px solid transparent;border-radius:3px;background:transparent;padding:.28rem .38rem;color:inherit;font:inherit;line-height:1.35;outline:none}
.detail-inline-input:hover{background:#fff;border-color:#e1e5e9}
.detail-inline-input:focus{background:#fff;border-color:#86b7fe;box-shadow:0 0 0 .12rem rgba(13,110,253,.12)}
.detail-item-name{min-width:180px}
.detail-item-qty,.detail-item-price{min-width:78px}
.detail-item-actions{width:1%;white-space:nowrap}
.detail-item-buttons{display:flex;justify-content:flex-end;align-items:center;gap:.45rem;white-space:nowrap}
.detail-save-link,.detail-delete-link,.detail-add-link{display:inline-block;border:0;background:none;padding:.2rem 0;font:inherit;font-size:.82rem;white-space:nowrap;text-decoration:none;cursor:pointer}
.detail-save-link{color:#0d6efd}
.detail-delete-link{color:#dc3545}
.detail-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:29px;height:29px;padding:5px;border:1px solid #dce3eb;border-radius:6px;background:#fff;color:#374151;cursor:pointer;transition:background .15s,border-color .15s}.detail-icon-btn svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}.detail-icon-btn:hover{background:#eef4ff;border-color:#b6ccf5}.detail-icon-btn.danger{color:#dc3545}.detail-icon-btn.danger:hover{background:#fff1f2;border-color:#f1b8bd}
.detail-save-link:hover,.detail-delete-link:hover,.detail-add-link:hover{text-decoration:underline}
.detail-add-link{display:inline-flex;align-items:center;gap:.35rem;color:#0d6efd;padding:.28rem .6rem;border:1px solid #0d6efd;border-radius:4px;background:#fff;font-weight:500}.detail-add-link:hover{background:#eef4ff;text-decoration:none}
.detail-add-form{max-width:none;padding:10px 0;border-top:1px solid #e4e8ec}
.detail-add-form .form-control{font-size:.85rem}
@media(max-width:767.98px){.detail-panel{padding:12px 8px}.detail-items-table{min-width:650px!important}.detail-items-table thead th{font-size:.75rem!important}.detail-item-buttons{gap:.35rem}}

/* Task comments */
.task-comments-table{width:100%;min-width:0!important;font-size:.82rem;margin-bottom:8px!important}
.task-comments-table thead th{font-size:.9rem;font-weight:700;padding:.4rem .45rem;border-bottom:1px solid #dee2e6}
.task-comments-table tbody td{padding:.42rem .45rem;border-bottom:1px solid #e4e8ec;vertical-align:top}
.task-comment-text{white-space:pre-wrap;overflow-wrap:anywhere}
.task-comment-form{max-width:1000px;padding:8px 0}
.task-comment-input{width:100%;resize:vertical}
.task-comment-employee{width:100%}
.task-comment-error:empty{display:none}
.task-comment-add{border:1px solid #0d6efd;border-radius:4px;padding:.28rem .6rem}

.task-comments-table thead th{font-size:.9rem;font-weight:700}.task-comments-table tbody td:last-child{width:auto}

.editable-cell.record-locked{cursor:not-allowed;background:#f8fafc;color:#64748b}
.record-locked-panel .detail-inline-input:read-only{background:#f8fafc;color:#64748b;cursor:not-allowed}
.record-locked-panel button:disabled{opacity:.45;cursor:not-allowed}

.crm-stat{height:100%;padding:14px 16px;border:1px solid #e5e9ef;border-radius:10px;background:#fff;display:flex;flex-direction:column;gap:4px}
.crm-stat span{font-size:.82rem;color:#64748b}.crm-stat strong{font-size:1.45rem;line-height:1.2}
.crm-filters{border-radius:10px}.crm-filters .form-select,.crm-filters .form-control{font-size:.9rem}
.work-row.row-overdue>td{background:#fff7f7}.work-row.row-overdue .due-date-cell{color:#b42318;font-weight:700}
.payment-select{min-width:125px;font-size:.82rem}.payment-select[value="paid"]{color:#167447}

.detail-history-toggle{border:0;background:none;padding:.35rem 0;color:#475569;font-weight:600;font-size:.88rem;cursor:pointer}.detail-history-entry{display:flex;gap:12px;padding:7px 0;border-bottom:1px solid #edf0f4;font-size:.82rem}.detail-history-entry time{flex:0 0 125px;color:#64748b}.detail-history-entry span{color:#334155}

.crm-readonly .editable-cell{cursor:default!important}.crm-readonly .status-select,.crm-readonly .payment-select{pointer-events:none;opacity:.8}.crm-readonly .detail-add,.crm-readonly .detail-item-save,.crm-readonly .detail-item-delete-toggle,.crm-readonly .task-comment-add{display:none!important}

/* Read-only role: filters remain interactive, but no edit hints or warning row colors. */
.crm-readonly .crm-filters select,.crm-readonly .crm-filters input{pointer-events:auto!important;opacity:1!important;cursor:auto!important}
.crm-readonly .editable-cell::after{display:none!important}
.crm-readonly .editable-cell:hover .editable-value{text-decoration:none!important}
.crm-readonly .work-row.row-overdue>td{background:inherit!important}
.crm-readonly .work-row.row-overdue .due-date-cell{color:inherit!important;font-weight:normal!important}

/* Interactive summary cards and home/reset control, for all roles. */
.brand{cursor:pointer;display:inline-block;border-radius:6px;transition:background-color .15s,padding .15s;margin-left:-6px;padding:0 6px}
.brand:hover{background:#e8edf5}
.brand:focus-visible{outline:2px solid #86b7fe;outline-offset:2px}
.crm-stat{cursor:pointer;transition:background-color .15s,border-color .15s,box-shadow .15s}
.crm-stat:hover{background:#f3f7ff;border-color:#b8cdf5}
.crm-stat.is-selected{background:#e7f0ff;border-color:#7da9ef;box-shadow:inset 0 0 0 1px #7da9ef}
.crm-stat:focus-visible{outline:2px solid #86b7fe;outline-offset:2px}

.new-record-table{width:100%;table-layout:fixed}
.new-record-table td:last-child{width:10%;min-width:92px;padding-left:.35rem}
.new-record-submit{width:100%;min-width:0;white-space:nowrap}

/* Product/pricelist autocomplete inside order composition */
.product-suggestions{display:none;position:absolute;left:0;right:0;top:100%;z-index:1050;background:#fff;border:1px solid #dee2e6;border-radius:.375rem;box-shadow:0 .25rem .75rem rgba(0,0,0,.12);overflow:hidden;max-height:240px;overflow-y:auto}.product-suggestions .entity-option{font-size:.875rem;border-bottom:1px solid #f1f3f5}.product-suggestions .entity-option:last-child{border-bottom:0}.product-unit-label{min-height:1rem}
