.modal-backdrop{position:fixed;inset:0;z-index:70;background:rgba(7,22,43,.58);backdrop-filter:blur(3px);opacity:0;pointer-events:none;transition:opacity .2s}
.modal-backdrop.open{opacity:1;pointer-events:auto}
.app-modal{position:fixed;z-index:71;top:50%;left:50%;width:min(520px,calc(100vw - 28px));max-height:calc(100dvh - 28px);overflow:hidden;background:#fff;border:1px solid rgba(255,255,255,.6);border-radius:16px;box-shadow:0 28px 90px rgba(4,17,35,.3);opacity:0;pointer-events:none;transform:translate(-50%,-47%) scale(.985);transition:opacity .2s,transform .2s}
.app-modal.open{opacity:1;pointer-events:auto;transform:translate(-50%,-50%) scale(1)}
.app-modal.wide{width:min(760px,calc(100vw - 28px))}
.app-modal.xwide{width:min(1080px,calc(100vw - 28px))}
body.modal-open{overflow:hidden}
.modal-loading{min-height:190px;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--muted);font-size:11px}
.modal-loading p{margin:10px 0 0}
.modal-head{position:sticky;top:0;z-index:3;display:flex;justify-content:space-between;align-items:flex-start;gap:20px;padding:22px 26px 17px;background:#fff;border-bottom:1px solid var(--line)}
.modal-head .eyebrow{font-size:11px;font-weight:700;letter-spacing:1.3px;color:#4772c9}
.modal-head h2{font:800 19px/1.3 Manrope;margin:5px 0 0;color:#12243d}
.modal-head p{font-size:12.5px;line-height:1.6;color:var(--muted);margin:6px 0 0}
.modal-body{padding:20px 26px;overflow:auto;overscroll-behavior:contain}
.modal-foot{position:sticky;bottom:0;z-index:3;display:flex;justify-content:flex-end;align-items:center;gap:9px;padding:14px 26px;background:#fff;border-top:1px solid var(--line)}
.modal-foot>div{margin-right:auto;display:flex;flex-direction:column;gap:4px}
.modal-foot>div b{font-size:12.5px}
.modal-foot>div small{font-size:11.5px;color:var(--muted)}
.campaign-modal-form{display:flex;flex-direction:column;max-height:calc(100dvh - 28px)}
.campaign-modal-form .modal-body{flex:1;min-height:0}
.form-section{padding:0 0 20px;margin:0 0 20px;border-bottom:1px solid #edf0f4}
.form-section:last-child{padding-bottom:0;margin-bottom:0;border:0}
.section-title{display:flex;align-items:flex-start;gap:11px;margin-bottom:15px}
.section-title>span{width:25px;height:25px;flex:none;display:grid;place-items:center;border-radius:8px;background:#edf3ff;color:#2d61ce;font:700 10px Manrope}
.section-title h3{font:700 12px Manrope;margin:1px 0 0}
.section-title p{font-size:12.5px;color:var(--muted);margin:5px 0 0}
.form-grid{display:grid;gap:0 13px}
.form-grid.two{grid-template-columns:repeat(2,minmax(0,1fr))}
.form-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}
.form-grid .span-2{grid-column:span 2}
.form-grid .span-3{grid-column:1/-1}
.form-grid .field textarea{min-height:64px}
.input-suffix{display:flex;align-items:center;border:1px solid #dce3eb;border-radius:8px;overflow:hidden}
.input-suffix input{border:0!important;box-shadow:none!important}
.input-suffix span{padding:0 10px;color:#8290a2;font-size:12px;white-space:nowrap}
.scope-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.scope-card{display:flex;align-items:flex-start;gap:10px;padding:13px;border:1px solid var(--line);border-radius:10px;cursor:pointer;transition:.15s}
.scope-card:has(input:checked){border-color:#6d91ed;background:#f4f7ff;box-shadow:0 0 0 2px rgba(54,102,220,.08)}
.scope-card input{margin:3px 0 0;accent-color:var(--blue)}
.scope-card span{display:flex;flex-direction:column;gap:5px}
.scope-card b{font-size:14px}
.scope-card small{font-size:12.5px;line-height:1.5;color:var(--muted)}
.scope-card i{margin-left:auto;color:#315fca;font-style:normal}
.filter-builder{margin-top:13px;padding:13px;background:#f7f9fc;border:1px solid #e9edf3;border-radius:10px}
.filter-toolbar{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px}
.filter-toolbar label{font-size:12px;font-weight:600;color:#586a80}
.filter-toolbar select,.filter-rule select,.filter-rule input{height:34px;border:1px solid #dce3eb;border-radius:7px;background:#fff;padding:0 9px;font-size:12.5px;color:var(--ink);min-width:0}
.filter-toolbar select{margin-left:6px}
.filter-rule{display:grid;grid-template-columns:minmax(130px,1fr) minmax(110px,.8fr) minmax(130px,1fr) 30px;gap:7px;margin-top:7px}
.filter-rule .remove-rule{width:30px;height:34px;border:1px solid #efd6d9;border-radius:7px;background:#fff;color:#d34b5a;font-size:17px;cursor:pointer}
.selection-label{display:flex;align-items:center;justify-content:space-between;font-size:13.5px;color:#50627a;margin:14px 0 9px}
.selection-label small{font-size:12px;font-weight:500;color:#7d8b9e}
.team-card-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.team-select{position:relative;display:flex;align-items:center;gap:9px;padding:10px;border:1px solid var(--line);border-radius:9px;cursor:pointer;min-width:0}
.team-select:has(input:checked){border-color:#6388e5;background:#f3f7ff}
.team-select input{accent-color:var(--blue)}
.team-select>span:nth-of-type(2){min-width:0;display:flex;flex-direction:column;gap:3px}
.team-select b{font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.team-select small{font-size:12.5px;color:var(--muted)}
.team-select>i{margin-left:auto;color:#2863dd;font-style:normal;opacity:0}
.team-select:has(input:checked)>i{opacity:1}
.select-avatar{width:27px;height:27px;flex:none;display:grid;place-items:center;border-radius:8px;background:#e8eefb;color:#355da9;font-size:12px;font-weight:700}
.employee-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px}
.employee-toolbar .selection-label{flex:1}
.employee-toolbar .filter-control{max-width:280px}
.employee-card-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;max-height:250px;overflow:auto;padding:1px 2px 2px}
.employee-card{position:relative;display:flex;align-items:center;gap:9px;min-width:0;padding:10px;border:1px solid var(--line);border-radius:9px;cursor:pointer;transition:.15s}
.employee-card:has(input:checked){border-color:#6388e5;background:#f3f7ff}
.employee-card input{position:absolute;opacity:0;pointer-events:none}
.employee-avatar{position:relative;width:31px;height:31px;flex:none;display:grid;place-items:center;border-radius:50%;background:#e8eefb;color:#315da9;font-size:12px;font-weight:700}
.presence{position:absolute;right:-1px;bottom:-1px;width:10px;height:10px;border:2px solid #fff;border-radius:50%;background:#aab4c0}
.presence.online{background:#14aa7e}
.employee-copy{display:flex;flex-direction:column;gap:3px;min-width:0}
.employee-copy b,.employee-copy small,.employee-copy em{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.employee-copy b{font-size:14px}
.employee-copy small{font-size:12.5px;color:#728198}
.employee-copy em{font-size:12px;color:#8491a2;font-style:normal}
.employee-card:has(.presence.online) .employee-copy em{color:#078b67}
.card-check{margin-left:auto;flex:none;width:17px;height:17px;display:grid;place-items:center;border:1px solid #dbe2ec;border-radius:5px;color:transparent;font-size:10px}
.employee-card:has(input:checked) .card-check{background:var(--blue);border-color:var(--blue);color:#fff}
.campaign-modal-form .modal-foot .button{flex:none}
.app-modal .settings-note{padding:12px 14px;background:#f4f7fb;border-radius:9px}
.app-modal .settings-note b{font-size:12px}
.app-modal .settings-note p{font-size:12px;line-height:1.5;color:var(--muted);margin:5px 0 0}
@media(max-width:900px){.team-card-grid,.employee-card-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:650px){.app-modal,.app-modal.wide,.app-modal.xwide{width:calc(100vw - 16px);max-height:calc(100dvh - 16px);border-radius:12px}.campaign-modal-form{max-height:calc(100dvh - 16px)}.modal-head{padding:16px 16px 13px}.modal-body{padding:15px 16px}.modal-foot{padding:12px 16px;flex-wrap:wrap}.modal-foot>div{flex-basis:100%;margin:0}.form-grid.two,.form-grid.three,.scope-options{grid-template-columns:1fr}.form-grid .span-2,.form-grid .span-3{grid-column:auto}.team-card-grid,.employee-card-grid{grid-template-columns:1fr 1fr}.employee-toolbar{align-items:flex-start;flex-direction:column;gap:0}.employee-toolbar .filter-control{max-width:none;width:100%}.filter-rule{grid-template-columns:1fr 1fr 30px}.filter-rule [data-filter-value]{grid-column:1/3;grid-row:2}.filter-rule .remove-rule{grid-column:3;grid-row:1}.filter-toolbar{align-items:flex-start;flex-direction:column}.modal-foot .button{flex:1}}
@media(max-width:420px){.team-card-grid,.employee-card-grid{grid-template-columns:1fr}.modal-foot{gap:6px}.modal-foot .button{padding:0 9px}}

/* Bố cục modal: khung ngoài là flex cột, header/footer cố định, chỉ .modal-body cuộn.
   Không dựa vào position:sticky nên footer luôn nằm đáy popup và khung ngoài không bao giờ cần cuộn. */
.app-modal{display:flex;flex-direction:column;overflow:hidden}
.app-modal>form,.app-modal>div:not(.modal-loading){display:flex;flex-direction:column;flex:0 1 auto;min-height:0;max-height:100%}
.app-modal .modal-head,.app-modal .modal-foot{position:static;flex:none}
.app-modal .modal-body{flex:1 1 auto;min-height:0;max-height:none;overflow:auto}

/* Radio/checkbox ẩn trong thẻ chọn dùng position:absolute: thẻ phải là containing block, nếu không input bị neo vào .app-modal
   (nằm ngoài vùng cuộn .modal-body). Khi bấm thẻ, trình duyệt focus input và cuộn cả khung modal để hiện nó, đẩy form lên và lộ khoảng trắng dưới footer. */
.scope-card,.select-card{position:relative}

/* Bảng nhân viên trong popup theo dõi chiến dịch: nhỏ hơn 1 đơn vị để vừa khung hiển thị. */
.monitor-agents-title{font-size:12.5px}.monitor-agents .data-table th{font-size:10px}.monitor-agents .data-table td{font-size:12px}.monitor-agents .data-table td strong{font-size:12.5px}.monitor-agents .data-table td small{font-size:11.5px}.monitor-agents .status-badge{font-size:10.5px}
.monitor-agents .overdue-text{color:#c2410c;font-weight:600}.monitor-agents [data-release-agent]{margin-top:5px}
.related-contracts{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:0 0 14px;padding:11px 16px;background:#fff4e0;border:1px solid #f2c27a;border-left:4px solid #f29a32;border-radius:10px;color:#6b4300}.related-contracts[hidden]{display:none}.customer-detail .related-contracts{margin:0;border-radius:0;border-width:1px 0;border-left-width:4px}.related-icon{font-size:18px;line-height:1}.related-text{display:flex;flex-direction:column;gap:2px;min-width:200px}.related-text b{font-size:13.5px;color:#7a4a00}.related-text span{font-size:11px;color:#8a6a2f}.related-chips{display:flex;flex-wrap:wrap;gap:7px;margin-left:auto}.related-chip{font:inherit;font-size:12px;font-weight:700;padding:5px 11px;border-radius:999px;border:1px solid #e0a24a;background:#fff;color:#8a4b00;cursor:pointer}button.related-chip:hover{background:#f29a32;color:#fff;border-color:#f29a32}button.related-chip:disabled{opacity:.6;cursor:wait}.related-chip.current{background:#f6dfb8;border-color:#e0c18a;color:#6b4300;cursor:default}.related-chip em{font-style:normal;font-weight:500;font-size:10.5px;opacity:.8}
.related-chip.static{cursor:default}
.column-picker{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:14px}.column-group{border:1px solid var(--line);border-radius:10px;padding:10px 14px 12px;margin:0}.column-group legend{padding:0 6px;font-size:11px;font-weight:700;color:#728095;letter-spacing:.4px}.column-option{display:flex;align-items:center;gap:8px;padding:5px 0;font-size:13px;cursor:pointer}.column-option input{margin:0}
.copy-inline{display:flex;align-items:center;gap:8px;flex-wrap:wrap;word-break:break-all}.copy-inline .copy-chip{flex:none}
.column-picker{display:block}.column-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}.column-row{display:grid;grid-template-columns:22px 1fr auto auto;align-items:center;gap:10px;padding:7px 10px;border:1px solid var(--line);border-radius:8px;background:#fff}.column-row.dragging{opacity:.45;border-style:dashed}.column-handle{cursor:grab;color:#8996a6;font-size:16px;line-height:1;user-select:none}.column-row small{color:#8996a6;font-size:11px}.column-move{display:flex;gap:3px}.column-move button{width:24px;height:24px;border:1px solid var(--line);background:#f8f9fb;border-radius:5px;font-size:9px;cursor:pointer;color:#506078}.column-move button:hover{background:#e8f0ff}.column-row .column-option{padding:0}
/* Chrome đóng ngay danh sách select dài khi popup thấp (chớp): giới hạn chiều cao danh sách bằng base-select. */
@supports (appearance:base-select){
.filter-rule select[data-filter-field]{appearance:base-select;display:flex;align-items:center;justify-content:space-between;flex-wrap:nowrap;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.filter-rule select[data-filter-field]::picker-icon{flex:none;margin-left:auto;padding-left:6px;font-size:10px;color:#7a8aa0}
.filter-rule select[data-filter-field]::picker(select){appearance:base-select;max-height:min(320px,50vh);margin-top:4px;padding:4px;border:1px solid #dce3eb;border-radius:8px;background:#fff;box-shadow:0 12px 32px rgba(5,23,48,.18);overflow:auto}
.filter-rule select[data-filter-field] option{padding:7px 10px;border-radius:5px;font-size:12.5px;white-space:nowrap;color:var(--ink)}
.filter-rule select[data-filter-field] option:hover,.filter-rule select[data-filter-field] option:focus{background:#eef3fc}
.filter-rule select[data-filter-field] option:checked{background:#e3ecfd;font-weight:700}
.filter-rule select[data-filter-field] option::checkmark{display:none}
}
