/* SAMAMI v74 - correct the one contradictory theme badge;
   keep the same step typography and compact dimensions. */
html[data-samami-theme="light"] body.sam-configurator-document #root
  [data-qa="studio-guided-preview"] .cw-stage-head > span {
  background: #e8f2fc !important;
  color: #174b76 !important;
  border: 1px solid #bfd4e9 !important;
  box-shadow: 0 1px 2px rgba(36,80,112,.08);
}
html[data-samami-theme="dark"] body.sam-configurator-document #root
  [data-qa="studio-guided-preview"] .cw-stage-head > span {
  background: #1b354a !important;
  color: #e8f4ff !important;
  border: 1px solid #49677f !important;
}
html[data-samami-theme] body.sam-configurator-document #root
  [data-qa="studio-guided-preview"] .cw-stage-head > span {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 31px;
  border-radius: 100px;
  padding-inline: 12px;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ERP unified UI contract.  Extend the existing style grammar, rather than
   changing color variables or adding another independent component system. */
#root .samami-enterprise-shell {
  --erp74-action-height: 40px;
  --erp74-toolbar-gap: 10px;
  --erp74-border-radius: 12px;
  --erp74-focus-ring: #2378cc;
}
#root .samami-enterprise-shell .erp-page-surface
:is(.sam-world-toolbar,.sam-customer-controls,.sam-erp4-toolbar,.erp-toolbar,.sam-workspace-toolbar) {
  display: flex;
  align-items: center;
  align-content: start;
  flex-wrap: wrap;
  gap: var(--erp74-toolbar-gap) !important;
  min-width: 0;
  max-width: 100%;
  border-radius: var(--erp74-border-radius) !important;
}
#root .samami-enterprise-shell .erp-page-surface
:is(.sam-world-toolbar,.sam-customer-controls,.sam-erp4-toolbar,.erp-toolbar,.sam-workspace-toolbar)
:is(.sam-world-toolbar__search,.sam-master-search,input[type="search"]) {
  box-sizing: border-box;
  min-width: 0;
  flex: 1 1 230px;
}
#root .samami-enterprise-shell .erp-page-surface
:is(.sam-world-toolbar,.sam-customer-controls,.sam-erp4-toolbar,.erp-toolbar,.sam-workspace-toolbar)
:is(.sam-world-toolbar__filters,.sam-world-toolbar__actions,.sam-erp4-toolbar-actions,.sam-customer-toolbar-actions) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}
#root .samami-enterprise-shell .erp-page-surface
:is(.sam-world-toolbar,.sam-customer-controls,.sam-erp4-toolbar,.erp-toolbar,.sam-workspace-toolbar)
:is(button,a[role="button"],select,input[type="search"]) {
  min-height: var(--erp74-action-height) !important;
  max-width: 100%;
  line-height: 1.4;
}
#root .samami-enterprise-shell .erp-page-surface
:is(.sam-world-toolbar,.sam-customer-controls,.sam-erp4-toolbar,.erp-toolbar,.sam-workspace-toolbar)
:is(input[type="search"],input[type="text"],select) {
  min-width: 0;
  color: var(--sam-consistent-ink,inherit);
  background: var(--sam-consistent-surface,inherit);
  border-color: var(--sam-consistent-border,inherit);
}
#root .samami-enterprise-shell .erp-page-surface
:is(.sam-world-toolbar,.sam-customer-controls,.sam-erp4-toolbar,.erp-toolbar,.sam-workspace-toolbar)
:is(input[type="search"],input[type="text"],select)::placeholder {
  color: var(--sam-consistent-muted,#64748b);
  opacity: 1;
}
#root .samami-enterprise-shell .erp-page-surface
:is(.sam-world-browser__head,.sam-world-section-header,.sam-record-table-shell > header,.sam-operational-section > header)
{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 12px;
  row-gap: 8px;
  min-width: 0;
  max-width: 100%;
}
#root .samami-enterprise-shell .erp-page-surface
:is(.sam-world-browser__head,.sam-world-section-header,.sam-record-table-shell > header,.sam-operational-section > header)
:is(h2,h3,p,small,span) {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
#root .samami-enterprise-shell .erp-page-surface
:is(.sam-erp4-card,.sam-world-card,.erp-card,.sam-world-browser,.sam-record-table-shell,.sam-customer-master,.fin49-panel) {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: var(--erp74-border-radius) !important;
}
#root .samami-enterprise-shell .erp-page-surface
:is(button,a,input,select,textarea):focus-visible {
  outline: 2px solid var(--erp74-focus-ring) !important;
  outline-offset: 2px;
}
#root .samami-enterprise-shell .erp-page-surface
:is(.sam-record-table-scroll,.sam-world-browser,.sam-erp4-board) {
  max-width: 100%;
  min-width: 0;
}
@media(max-width: 720px) {
  #root .samami-enterprise-shell .erp-page-surface
  :is(.sam-world-toolbar,.sam-customer-controls,.sam-erp4-toolbar,.erp-toolbar,.sam-workspace-toolbar)
  :is(.sam-world-toolbar__search,.sam-master-search,input[type="search"]) {
    flex: 1 1 100%;
    width: 100%;
  }
  #root .samami-enterprise-shell .erp-page-surface
  :is(.sam-world-toolbar,.sam-customer-controls,.sam-erp4-toolbar,.erp-toolbar,.sam-workspace-toolbar)
  :is(.sam-world-toolbar__filters,.sam-world-toolbar__actions) {
    width: 100%;
    max-width: 100%;
  }
}
/* Existing listbox menus can be portaled outside ERP's shell, and must
   receive page-theme tokens independently of the parent. */
html[data-samami-theme="light"] :is(.sam-erp-menu__portal,.sam-erp-menu__list) {
  color: #1b344e !important;
  background: #ffffff !important;
  border-color: #c5d5e5 !important;
}
html[data-samami-theme="dark"] :is(.sam-erp-menu__portal,.sam-erp-menu__list) {
  color: #f2f6ff !important;
  background: #172737 !important;
  border-color: #435a70 !important;
}


/* CRM receives an additional late-loaded ERP-five-workspaces stylesheet.
 * This is the exact same shared grammar, scoped more tightly so late loads
 * cannot silently revert the radius / control grouping in this page. */
html[data-samami-theme] body #root .samami-enterprise-shell
.erp-page-surface .sam-erp4-card {
  border-radius: var(--erp74-border-radius) !important;
}
html[data-samami-theme] body #root .samami-enterprise-shell
.erp-page-surface .sam-erp4-toolbar {
  border-radius: var(--erp74-border-radius) !important;
  flex-wrap: wrap !important;
  gap: var(--erp74-toolbar-gap) !important;
}
html[data-samami-theme] body #root .samami-enterprise-shell
.erp-page-surface .sam-erp4-toolbar input[type="search"] {
  min-height: var(--erp74-action-height) !important;
  min-width: 0 !important;
}
html[data-samami-theme] body #root .samami-enterprise-shell
.erp-page-surface :is(.sam-world-browser,.sam-world-card,.erp-card,.sam-customer-master,.fin49-panel) {
  border-radius: var(--erp74-border-radius) !important;
}
