/* All portal styles are scoped; legacy views retain their own DOM and state. */
#adsView.sx-portals-open > :not(#sxPortals) { display: none !important; }
#sxPortals[hidden] { display: none !important; }
#sxPortals { width: 100%; min-width: 0; color: inherit; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
#sxPortals * { box-sizing: border-box; }
#sxPortals .sx-p-heading { display: flex; align-items: center; gap: 8px; min-height: 32px; margin-bottom: 8px; }
#sxPortals .sx-p-heading button.sx-p-back { display: grid; place-items: center; width: 44px; height: 44px; min-height: 44px; flex: 0 0 44px; margin: -6px 0 -6px -8px; padding: 0; border: 0; border-radius: 50%; background: transparent; }
#sxPortals .sx-p-back svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
#sxPortals .sx-p-heading h2 { min-width: 0; flex: 1; font-size: 16px; line-height: 1.3; font-weight: 600; }
#sxPortals h2 { font-size: 20px; margin: 0; overflow-wrap: anywhere; }
#sxPortals h3 { font-size: 16px; margin: 0 0 10px; }
#sxPortals p { line-height: 1.5; margin: 8px 0; overflow-wrap: anywhere; }
#sxPortals .sx-p-sub { font-size: 13px; opacity: .75; }
#sxPortals .sx-p-card { background: var(--panel, #fff); border: 1px solid var(--line, #ded8ce); border-radius: 16px; padding: 16px; margin: 12px 0; overflow-wrap: anywhere; }
#sxPortals .sx-p-list { display: grid; gap: 10px; }
#sxPortals button, #sxPortals .sx-p-profile-card { font: inherit; cursor: pointer; min-height: 44px; border-radius: 12px; padding: 11px 14px; border: 1px solid var(--line, #ded8ce); color: inherit; background: var(--control-bg, #fff); white-space: normal; overflow-wrap: anywhere; }
#sxPortals button:focus-visible, #sxPortals input:focus-visible, #sxPortals textarea:focus-visible { outline: 3px solid #548fdb; outline-offset: 2px; }
#sxPortals button:disabled { opacity: .5; cursor: default; }
#sxPortals .sx-p-profile { text-align: left; display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; width: 100%; }
#sxPortals .sx-p-initial { border-radius: 50%; display: grid; place-items: center; width: 40px; height: 40px; background: rgba(59,130,246,.13); font-weight: 700; }
#sxPortals .sx-p-profile-card { cursor: default; grid-template-columns: 42px minmax(0, 1fr); }
#sxPortals .sx-p-profile-card .sx-p-actions { grid-column: 1 / -1; margin-top: 0; }
#sxPortals .sx-p-profile strong { display: block; }
#sxPortals .sx-p-profile small { display: block; margin-top: 5px; }
#sxPortals .sx-p-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#sxPortals .sx-p-actions button { width: auto; flex: 1 1 auto; }
#sxPortals .sx-p-primary { background: var(--accent, #1e6b5f); color: var(--accent-contrast, #fff); border-color: transparent; }
#sxPortals .sx-p-error { border: 1px solid #bb4f43; padding: 12px; border-radius: 12px; margin: 12px 0; overflow-wrap: anywhere; }
#sxPortals .sx-p-status { min-height: 20px; font-size: 14px; margin: 8px 0; }
#sxPortals .sx-p-status:empty { display: none; }
#sxPortals .sx-p-badge { display: inline-block; border-radius: 8px; background: rgba(40,140,90,.13); padding: 3px 8px; font-size: 12px; }
#sxPortals .sx-p-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 10px; }
#sxPortals .sx-p-details { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 14px; }
#sxPortals .sx-p-details dt { opacity: .72; }
#sxPortals .sx-p-details dd { margin: 0; overflow-wrap: anywhere; text-align: right; }
#sxPortals label { display: block; margin: 14px 0 6px; font-size: 14px; }
#sxPortals input:not([type=checkbox]), #sxPortals textarea { font: inherit; font-size: 16px; color: inherit; background: var(--input-bg, transparent); width: 100%; min-width: 0; padding: 12px; border: 1px solid var(--border-color, #8c8c8c); border-radius: 10px; }
#sxPortals input[type=checkbox] { margin-right: 9px; width: 18px; height: 18px; vertical-align: middle; }
#sxPortals .sx-p-thread { display: flex; flex-direction: column; gap: 9px; padding: 8px 0; }
#sxPortals .sx-p-message { max-width: 90%; border-radius: 14px; padding: 11px 13px; background: rgba(128,128,128,.12); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; }
#sxPortals .sx-p-message.own { align-self: flex-end; background: rgba(45,115,210,.16); }
#sxPortals .sx-p-message small { display: block; opacity: .65; margin-top: 6px; font-size: 11px; }
#sxPortals .sx-p-compose { position: sticky; bottom: 0; padding: 10px 0 max(10px, env(safe-area-inset-bottom)); background: var(--panel, #fff); }
#sxPortals textarea { resize: vertical; min-height: 86px; max-height: 220px; }
#sxPortals .sx-p-loading { opacity: .72; padding: 24px 0; }
@media (max-width: 350px) { #sxPortals .sx-p-grid { grid-template-columns: 1fr; } #sxPortals .sx-p-card { padding: 12px; } }

/* Only customers with portal access get the compact three/four-tab layout. */
#customerTabs.sx-portals-navigation .customer-tab { flex: 1 1 auto; width: auto; min-width: 44px; padding: 4px 6px; white-space: normal; overflow-wrap: anywhere; line-height: 1.15; }
#customerTabs.sx-portals-navigation .customer-tab[hidden] { display: none !important; }
#sxPortals .sx-p-provider { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 14px; text-align: left; border: 1px solid var(--line, #ded8ce); border-radius: 16px; background: var(--panel, #fff); }
#sxPortals .sx-p-provider-icon { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; }
#sxPortals .sx-p-provider-icon[hidden] { display: none; }
#sxPortals .sx-p-provider strong { display: block; font-size: 16px; }
#sxPortals .sx-p-provider small { display: block; margin-top: 5px; font-size: 13px; line-height: 1.4; color: var(--muted); }
#sxPortals .sx-p-provider-arrow { font-size: 26px; color: var(--accent); }
#sxPortals .sx-p-provider-later { opacity: .65; }
@media (max-width: 360px) { #customerTabs.sx-portals-navigation .customer-tab { padding-inline: 4px; font-size: 12px; } }

/* Direct ad links use the existing portal action-button layout. */
#sxPortals .sx-p-actions .sx-p-external-link { display: flex; align-items: center; justify-content: center; flex: 1 1 auto; min-height: 44px; padding: 11px 14px; border: 1px solid var(--line, #ded8ce); border-radius: 12px; color: inherit; background: var(--control-bg, #fff); font: inherit; text-align: center; text-decoration: none; overflow-wrap: anywhere; }
#sxPortals .sx-p-external-link:focus-visible { outline: 3px solid #548fdb; outline-offset: 2px; }
