/**
 * B2B avatar / logo fallbacks — supplements existing #b2bModuleRoot rules.
 * Keeps layout dimensions; only robust visuals for missing/broken images.
 */

#b2bModuleRoot .b2b-account-card__avatar.b2b-avatar-tone,
#b2bModuleRoot .crm-detail-avatar.b2b-avatar-tone {
  position: relative;
  overflow: hidden;
  background: var(--b2b-av-bg, hsl(210 22% 93%)) !important;
  color: var(--b2b-av-fg, hsl(215 28% 28%)) !important;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: none;
}

#b2bModuleRoot .b2b-avatar-tone--neutral {
  --b2b-av-bg: hsl(210 22% 93%);
  --b2b-av-fg: hsl(215 28% 28%);
}

#b2bModuleRoot .b2b-account-card__avatar.b2b-avatar--contact {
  border-radius: 50%;
}

#b2bModuleRoot .crm-detail-avatar.b2b-avatar--contact-md {
  border-radius: 50%;
}

#b2bModuleRoot .crm-detail-avatar.b2b-avatar-tone.b2b-avatar--placeholder {
  background: hsl(210 22% 96%) !important;
  color: hsl(215 22% 42%) !important;
  border: 1px dashed rgba(100, 116, 139, 0.35);
}

#b2bModuleRoot .b2b-account-card__avatar .b2b-avatar__img,
#b2bModuleRoot .crm-detail-avatar .b2b-avatar__img--md {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

#b2bModuleRoot .b2b-avatar__fb {
  position: relative;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-align: center;
}

#b2bModuleRoot .b2b-avatar__fb[hidden] {
  display: none !important;
}

#b2bModuleRoot .b2b-avatar__tx {
  display: block;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.02em;
}

#b2bModuleRoot .dealer-pro-card__media {
  position: relative;
}

#b2bModuleRoot .dealer-pro-card__ph.b2b-product-visual .b2b-avatar__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#b2bModuleRoot .dealer-pro-card__ph.b2b-product-visual {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: var(--b2b-av-bg, #f4f6f9);
  color: var(--b2b-av-fg, #475569);
}

#b2bModuleRoot .dealer-pro-card__ph.b2b-product-visual .b2b-avatar__fb--product .b2b-avatar__tx {
  font-size: 15px;
}

#b2bModuleRoot .dealer-drawer-hero.b2b-product-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--b2b-av-bg, #f4f6f9);
  color: var(--b2b-av-fg, #475569);
}

#b2bModuleRoot .dealer-drawer-hero.b2b-product-visual .b2b-avatar__img--hero {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

#b2bModuleRoot .dealer-drawer-hero.b2b-product-visual .b2b-avatar__fb--product .b2b-avatar__tx {
  font-size: 22px;
  font-weight: 800;
}

/* ---- B2B drawer header (premium band) ---- */

#b2bModuleRoot .crm-firms-drawer-head.b2b-drawer-head--premium {
  padding: 0 0 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.9) 0%, rgba(255, 255, 255, 0) 100%);
}

#b2bModuleRoot .b2b-drawer-hero-band {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px 10px;
}

#b2bModuleRoot .b2b-drawer-hero-band__identity {
  flex-shrink: 0;
}

#b2bModuleRoot .b2b-drawer-hero-band__identity .b2b-account-card__avatar {
  width: 44px;
  height: 44px;
  border-radius: 13px;
}

#b2bModuleRoot .b2b-drawer-hero-band__main {
  flex: 1;
  min-width: 0;
}

#b2bModuleRoot .b2b-drawer-hero-band__main .crm-firms-drawer-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
  line-height: 1.25;
}

#b2bModuleRoot .b2b-drawer-hero-band__mode {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.35;
}

#b2bModuleRoot .b2b-drawer-hero-band__sub {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.4;
}

#b2bModuleRoot .b2b-drawer-hero-band__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

#b2bModuleRoot .b2b-drawer-hero-band__risk-label {
  margin-left: 8px;
  font-size: 12px;
}

#b2bModuleRoot .b2b-drawer-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

#b2bModuleRoot .b2b-drawer-meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 11px;
  line-height: 1.3;
}

#b2bModuleRoot .b2b-drawer-meta-chip__lab {
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

#b2bModuleRoot .b2b-drawer-meta-chip__val {
  font-weight: 600;
  color: #0f172a;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#b2bModuleRoot .b2b-drawer-head-toolbar {
  padding: 0 16px 2px;
  display: flex;
  justify-content: flex-end;
}

#b2bModuleRoot .b2b-drawer-head-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#b2bModuleRoot .b2b-drawer-head-actions .b2b-drawer-close-btn {
  font-weight: 600;
}

#b2bModuleRoot .b2b-drawer-footer-actions {
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 4px;
}

#b2bModuleRoot .b2b-drawer-footer-actions .primary-btn {
  min-width: 120px;
}

#b2bModuleRoot .b2b-drawer-footer-actions .danger {
  margin-left: auto;
}

#b2bModuleRoot .b2b-drawer-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#b2bModuleRoot .b2b-drawer-status-pill--on {
  background: rgba(34, 197, 94, 0.12);
  color: #166534;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

#b2bModuleRoot .b2b-drawer-status-pill--off {
  background: rgba(248, 113, 113, 0.1);
  color: #991b1b;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

#b2bModuleRoot .b2b-drawer-status-pill--neutral {
  background: rgba(241, 245, 249, 0.95);
  color: #334155;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

/* ---- B2B Accounts / Dealers list cards (accounts section only) ---- */

#b2bModuleRoot .b2b-account-grid--dealers {
  gap: 16px;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer {
  padding: 16px 16px 14px;
  cursor: default;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__top--dealer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__identity-cluster {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__status-cluster {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__badge {
  font-size: 10px;
  padding: 5px 9px;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-risk-pill {
  min-width: 30px;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  padding-bottom: 2px;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__metric {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid rgba(226, 232, 240, 0.95);
  font-size: 11px;
  line-height: 1.3;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__metric-lab {
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__metric-val {
  font-weight: 600;
  color: #0f172a;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__actions--dealer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  margin-top: 0;
  border-top: 1px solid rgba(226, 232, 240, 0.95);
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__actions--dealer .table-action-chip {
  font-size: 12px;
  padding: 7px 11px;
  border-radius: 10px;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__action--primary {
  font-weight: 700;
  border-color: rgba(99, 102, 241, 0.45);
  background: linear-gradient(180deg, rgba(238, 242, 255, 0.95) 0%, rgba(224, 231, 255, 0.65) 100%);
  color: #312e81;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

#b2bModuleRoot .b2b-account-card.b2b-account-card--dealer .b2b-account-card__action--primary:hover {
  border-color: rgba(79, 70, 229, 0.55);
  color: #1e1b4b;
}

/* THIQ merged category/brand multi-select (B2B price + catalog rules) */
#b2bModuleRoot .thiq-merged-msel {
  position: relative;
  z-index: 1;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  overflow: visible;
}

#b2bModuleRoot .thiq-merged-msel.is-open {
  z-index: 25;
}

#b2bModuleRoot .thiq-merged-msel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

#b2bModuleRoot .thiq-merged-msel__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.3;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #312e81;
  max-width: 100%;
}

#b2bModuleRoot .thiq-merged-msel__chip-x {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  color: #64748b;
}

#b2bModuleRoot .thiq-merged-msel__chip-x:hover {
  color: #0f172a;
}

#b2bModuleRoot .thiq-merged-msel__search {
  width: 100%;
  position: relative;
  z-index: 2;
}

#b2bModuleRoot .thiq-merged-msel__panel {
  display: none;
  pointer-events: none;
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  max-height: 240px;
  overflow-y: auto;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

#b2bModuleRoot .thiq-merged-msel.is-open .thiq-merged-msel__panel {
  display: flex;
  pointer-events: auto;
}

#b2bModuleRoot .thiq-merged-msel__opt {
  text-align: left;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: #0f172a;
}

#b2bModuleRoot .thiq-merged-msel__opt:hover:not(:disabled) {
  background: rgba(241, 245, 249, 0.95);
}

#b2bModuleRoot .thiq-merged-msel__opt.is-on {
  opacity: 0.45;
  cursor: default;
}

#b2bModuleRoot .thiq-merged-msel__create {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px dashed rgba(99, 102, 241, 0.45);
  background: rgba(238, 242, 255, 0.5);
  color: #4338ca;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

#b2bModuleRoot .thiq-merged-msel__empty {
  padding: 10px;
  font-size: 12px;
  color: #64748b;
}
