/* Scoped cleanup: all roles share this one messenger, with existing theme tokens. */
html body #bpxsMessenger.mx-clean :is(.mx-more-filters,.mx-list-caption,.mx-filter-line,.mx-search-help,.mx-status-buttons .mx-count,.mx-history-buttons,#mxRoomHint){display:none!important}
html body #bpxsMessenger.mx-clean .mx-list-pane>.mx-filters{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px;padding:5px 10px!important;margin:0!important}
html body #bpxsMessenger.mx-clean .scope-symbol{display:none!important}
html body #bpxsMessenger.mx-clean .mx-status-buttons{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1.35fr) minmax(0,1fr) 30px;gap:3px;padding:4px 10px 10px!important;margin:0!important}
html body #bpxsMessenger.mx-clean :is(.mx-filters,.mx-status-buttons)>button{min-width:0!important;margin:0!important;padding:6px 3px!important;font-size:var(--fs-sm,12.5px)!important;white-space:nowrap;min-height:30px;border-radius:7px}
html body #bpxsMessenger.mx-clean .mx-search{padding:10px 10px 4px!important;margin:0!important}
html body #bpxsMessenger.mx-clean #mxSearch{width:100%;min-width:0;padding:9px 10px!important;font-size:var(--fs-md,13.5px)!important}
html body #bpxsMessenger.mx-clean .mx-chat-head{grid-template-columns:fit-content(35%) minmax(0,1fr) auto!important;gap:6px 9px!important}
html body #bpxsMessenger.mx-clean #mxClientProgress{justify-content:flex-start!important;justify-self:start;margin-right:auto!important}
html body #bpxsMessenger.mx-clean .mx-head-actions{justify-self:end}
html body #bpxsMessenger.mx-clean #mxChatName{font-size:var(--fs-xl,17px)!important}
html body #bpxsMessenger.mx-clean .mx-room-nav{justify-content:flex-start!important;flex-wrap:wrap;padding:8px 12px!important}
html body #bpxsMessenger.mx-clean .mx-room-nav>div:first-child{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
html body #bpxsMessenger.mx-clean .mx-recipient-label{color:var(--mx-muted);font-size:var(--fs-sm,12.5px)!important;margin-right:5px}
html body #bpxsMessenger.mx-clean :is(#mxClientRoom,#mxOfficeRoom,[data-value])[aria-pressed=false]{background:transparent!important;border-color:var(--mx-line)!important;color:var(--mx-muted)!important;box-shadow:none!important}
html body #bpxsMessenger.mx-clean .mx-compose-bottom{display:flex!important;align-items:center;gap:8px!important;flex-wrap:wrap}
html body #bpxsMessenger.mx-clean .mx-send-controls{display:flex;align-items:center;justify-content:flex-end;gap:8px;margin-left:auto;flex-wrap:nowrap}
html body #bpxsMessenger.mx-clean .mx-send-controls .mx-choice-row{display:flex;gap:5px;margin:0!important;padding:0!important;border:0!important;flex:none}
html body #bpxsMessenger.mx-clean .mx-send-controls button{white-space:nowrap;padding:7px 10px!important;min-height:34px}
html body #bpxsMessenger.mx-clean .mx-send-controls button[hidden]{display:none!important}
html body #bpxsMessenger.mx-clean #mxSend:disabled{opacity:.45;cursor:not-allowed}
html body #bpxsMessenger.mx-clean .mx-compose-top{min-height:0!important;margin:0!important;padding:0!important}
html body #bpxsMessenger.mx-clean #mxRecipient:empty{display:none!important}
html body #bpxsMessenger.mx-clean .mx-closing-instructions{display:grid!important;gap:8px;padding:0!important;margin:0 0 12px!important;border:0!important;background:none!important}
html body #bpxsMessenger.mx-clean .mx-closing-instructions>button{padding:10px 12px!important;text-align:left;justify-content:flex-start;width:100%;border:1px solid var(--mx-line);border-radius:9px;background:var(--mx-panel);color:var(--mx-ink)}
html body #bpxsMessenger.mx-clean #mxContext .mx-case-fold{margin:8px 0!important;border-radius:9px;padding:0!important}
html body #bpxsMessenger.mx-clean #mxContext .mx-case-fold>summary{min-height:38px!important;padding:8px 10px!important;font-size:var(--fs-md,13.5px)!important;gap:7px!important}
html body #bpxsMessenger.mx-clean #mxContext details>summary::after{content:''!important;display:block!important;box-sizing:border-box!important;flex:0 0 8px!important;width:8px!important;height:8px!important;min-width:8px!important;border:0!important;border-right:2px solid currentColor!important;border-bottom:2px solid currentColor!important;border-radius:0!important;background:none!important;transform:rotate(45deg)!important;margin:0 4px 4px auto!important}
html body #bpxsMessenger.mx-clean #mxContext details[open]>summary::after{transform:rotate(225deg)!important;margin-bottom:-4px!important}
html body #bpxsMessenger.mx-clean #mxContext details:not([open])>:not(summary){display:none!important}
html body #bpxsMessenger.mx-clean #mxContext .mx-work-section-head{justify-content:flex-start;flex-wrap:nowrap!important}
html body #bpxsMessenger.mx-clean #mxContext .mx-work-section-head h4{font-size:var(--fs-md,13.5px)!important;line-height:1.4!important}
html body #bpxsMessenger.mx-clean #mxContext .mx-work-section-head>button{margin:0!important;flex:0 0 23px!important;width:23px!important;min-width:23px!important;min-height:23px!important;height:23px!important;padding:0!important;border:0!important;background:transparent!important;box-shadow:none!important;font-size:var(--fs-2xl,22px)!important;line-height:1!important;font-weight:var(--fw-s,600)}
html body #bpxsMessenger.mx-clean #mxAddTask{color:var(--crm-task-accent,#8295ff)!important}
html body #bpxsMessenger.mx-clean #mxAddNote{color:var(--crm-note-ink,var(--work-note-ink,#E5A83D))!important}
html body #bpxsMessenger.mx-clean .mx-payment-fields{display:grid;gap:10px;min-width:0}
html body #bpxsMessenger.mx-clean .mx-payment-fields label{display:grid;gap:5px;color:var(--mx-muted);font-size:var(--fs-sm,12.5px)!important}
html body #bpxsMessenger.mx-clean .mx-payment-fields :is(input,select){width:100%;box-sizing:border-box;min-width:0;min-height:34px;padding:7px 9px!important;border:1px solid var(--mx-line);border-radius:7px;background:var(--mx-panel);color:var(--mx-ink);font-size:var(--fs-md,13.5px)!important}
html body #bpxsMessenger.mx-clean .mx-payment-fields output{font-size:var(--fs-sm,12.5px)!important;line-height:1.5;color:var(--mx-muted)}
html body #bpxsMessenger.mx-clean .mx-payment-error{font-size:var(--fs-sm,12.5px)!important;color:var(--wa-danger);margin:0!important}
html body #bpxsMessenger.mx-clean .mx-payment-error:empty{display:none}
html body #bpxsMessenger.mx-clean [data-payment-extras]{display:grid;gap:9px;padding-top:9px}
@media(max-width:1050px){html body #bpxsMessenger.mx-clean .mx-chat-head{grid-template-columns:minmax(0,1fr) auto!important}html body #bpxsMessenger.mx-clean .mx-head-actions{grid-column:2!important}html body #bpxsMessenger.mx-clean #mxClientProgress{grid-column:1 / -1!important;grid-row:2!important}html body #bpxsMessenger.mx-clean .mx-contact-line{grid-row:3!important}}

/* Bound the entire dialog and keep dismissal inside the viewport, including zoomed CRM. */
html:root body #bpxsMessenger.mx-clean[open]{position:fixed!important;inset:0!important;margin:auto!important;zoom:1!important;transform:none!important;width:min(1880px,98vw)!important;max-width:98vw!important;height:96dvh!important;max-height:96dvh!important;box-sizing:border-box!important}
html:root body #bpxsMessenger.mx-clean #mxClose{position:absolute!important;inset:8px 8px auto auto!important;z-index:50!important;display:flex!important;align-items:center;justify-content:center;width:36px!important;height:36px!important;min-width:36px!important;border:1px solid var(--mx-line);border-radius:8px;background:var(--mx-panel)!important}
html:root body #bpxsMessenger.mx-clean .mx-head-actions{padding-right:38px!important}
html body #bpxsMessenger.mx-office-view .mx-list-pane>.mx-filters{grid-template-columns:repeat(2,minmax(0,1fr))!important}
html body #bpxsMessenger.mx-office-view [data-mx-scope=all]{display:none!important}
@media(max-width:760px){html:root body #bpxsMessenger.mx-clean[open]{width:100vw!important;max-width:100vw!important;height:100dvh!important;max-height:100dvh!important;margin:0!important;border-radius:0!important}html:root body #bpxsMessenger.mx-clean .mx-top{padding-right:48px!important}html:root body #bpxsMessenger.mx-clean #mxClose{top:max(6px,env(safe-area-inset-top))!important}}

/* The context fills its resizable track: the legacy 270px overlay width left an empty column. */
@media(min-width:1001px){
 html body #bpxsMessenger.mx-clean .mx-context{width:100%!important;max-width:none!important;box-sizing:border-box!important;justify-self:stretch!important}
}
/* Separate identity, progress and contacts. Progress must never compete with toolbar width. */
html body #bpxsMessenger.mx-clean .mx-chat-head{grid-template-columns:minmax(0,1fr) auto!important;gap:7px 9px!important}
html body #bpxsMessenger.mx-clean #mxChatName{grid-column:1!important;grid-row:1!important}
html body #bpxsMessenger.mx-clean .mx-head-actions{grid-column:2!important;grid-row:1!important;min-width:0;flex-wrap:wrap}
html body #bpxsMessenger.mx-clean #mxPhone span{display:none!important}
html body #bpxsMessenger.mx-clean #mxClientProgress{grid-column:1 / -1!important;grid-row:2!important;flex-wrap:wrap!important;width:100%;box-sizing:border-box;gap:5px!important}
html body #bpxsMessenger.mx-clean .mx-contact-line{grid-column:1 / -1!important;grid-row:3!important;overflow-wrap:anywhere}
html body #bpxsMessenger.mx-clean .mx-back{grid-row:4!important}
html body #bpxsMessenger.mx-clean .mx-status-buttons{grid-template-columns:minmax(0,1fr) minmax(0,1fr) 30px!important}
html body #bpxsMessenger.mx-clean .mx-status-buttons>button:first-child{grid-column:1 / -1!important}
html body #bpxsMessenger.mx-clean #mxSalespersonRoom[hidden]{display:none!important}
html body #bpxsMessenger.mx-clean #mxSalespersonRoom[aria-pressed=false]{background:transparent!important;border-color:var(--mx-line)!important;color:var(--mx-muted)!important;box-shadow:none!important}
html body #bpxsMessenger.mx-clean.mx-office-view .office-compose-top #mxRecipient:not(:empty){display:block!important;flex:1 0 100%;margin:0 0 7px!important;text-align:left}
html body #bpxsMessenger.mx-office-view .mx-filters[aria-label="Odbiorcy"]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}
html body #bpxsMessenger.mx-office-view [data-mx-scope]{font-size:var(--fs-xs,11.5px)!important;min-height:30px!important;padding:5px 7px!important}
html body #bpxsMessenger.mx-accountant-office [data-mx-scope],html body #bpxsMessenger.mx-accountant-office #mxOfficeRoom,html body #bpxsMessenger.mx-accountant-office #mxSalespersonRoom{display:none!important}

html body #bpxsMessenger.mx-accountant-office :is(#mxClientProgress,#mxChatContacts,#mxDemoReceive,#mxReviewRow){display:none!important}
html body #bpxsMessenger.mx-accountant-office :is(button[aria-label="Demo: nowa wiadomość"],button[title="Demo: nowa wiadomość"],button[aria-label="Przekaż tę wiadomość do biura"]){display:none!important}
html body #bpxsMessenger.mx-office-view .mx-filters[aria-label="Odbiorcy"]{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:4px!important}
html body #bpxsMessenger .mx-logo,html body #accountantWorkspace [data-ac=contact-message]{color:var(--muted,#969ba4)!important;background:var(--premium-paper,var(--panel))!important;border-color:var(--premium-line,var(--line))!important}

/* Accountant: client list + conversation, with the same composer and persistent filters. */
html body #bpxsMessenger.mx-accountant-office .mx-layout{grid-template-columns:300px minmax(0,1fr)!important}
html body #bpxsMessenger.mx-accountant-office :is(#mxContext,#mxDetails,.mx-room-nav,.mx-list-pane>.mx-filters,.mx-top p,.mx-demo-label,#mxSignature,#mxMarkHandled,.mx-send-controls .mx-choice-row){display:none!important}
html body #bpxsMessenger.mx-accountant-office .mx-list-pane::before{content:'Klienci';display:block;padding:12px 12px 0;font-weight:var(--fw-b,700);color:var(--mx-ink)}
html body #bpxsMessenger.mx-accountant-office .mx-status-buttons{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1.4fr) 34px!important}
html body #bpxsMessenger.mx-accountant-office .mx-status-buttons>button:first-child{grid-column:auto!important}
html body #bpxsMessenger.mx-accountant-office [data-mx-status=reply]{display:none!important}
html body #bpxsMessenger.mx-accountant-office [data-mx-status=pinned]{grid-column:3!important;grid-row:1!important;justify-self:stretch!important}
html body #bpxsMessenger.mx-accountant-office .mx-chat-head{grid-template-columns:minmax(0,1fr) auto!important}
html body #bpxsMessenger.mx-accountant-office .mx-head-actions{position:static!important;grid-column:2!important;grid-row:1!important;justify-self:end!important;display:flex!important;gap:8px!important}
html body #bpxsMessenger.mx-accountant-office #mxPin{position:static!important;inset:auto!important;margin:0!important;flex:none!important}
html body #bpxsMessenger.mx-accountant-office #mxRecipient{display:block!important;text-align:left!important;color:var(--mx-muted)}
@media(max-width:760px){html body #bpxsMessenger.mx-accountant-office .mx-layout{grid-template-columns:minmax(0,1fr)!important}}
html body #bpxsMessenger.mx-accountant-office .mx-top>.mx-chip{display:none!important}
html body #bpxsMessenger.mx-accountant-office .mx-list-pane::before{display:none}
html body #bpxsMessenger.mx-accountant-office .mx-search::before{content:'Klienci';display:block;margin:0 0 7px;font-weight:var(--fw-b,700);color:var(--mx-ink)}

/* Center the actual star, not just its cell, in every role. */
html body #bpxsMessenger.mx-clean [data-mx-status=pinned]{display:flex!important;align-items:center!important;justify-content:center!important;text-align:center!important;padding-inline:0!important;gap:0!important;text-indent:0!important}
html body #bpxsMessenger.mx-clean #mxPin{display:inline-flex!important;align-items:center!important;justify-content:center!important;text-align:center!important;text-indent:0!important}
