/*
 * PlusERP Global Workspace Standardization — Phase 2
 * Compatibility/adoption layer. Every rule is opt-in through a workspace or
 * component class; no application logic, routing, or data behavior lives here.
 */

:is(.plus-workspace, .plus-workspace-standardized) {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin-inline: 0;
  color: var(--color-text-primary);
  font-family: var(--font-family-sans);
}

/* PlusERP authenticated global workspace header */
.page .global-workspace-head {
  width: 100%;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 2px 10px;
  border-bottom: 1px solid #e4eaf2;
  box-sizing: border-box;
}
.page .global-workspace-identity { display: grid; gap: 3px; min-width: 0; }
.page .global-workspace-identity h1 {
  margin: 0;
  color: #10213b;
  font-size: 21px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.page .global-workspace-identity p {
  margin: 0;
  color: #30496c;
  font-size: 12px;
  line-height: 1.25;
}
.page .global-workspace-tools { flex: 1 1 auto; min-width: 0; }
.page .global-workspace-tools .approval-header-controls { justify-content: flex-end; }
.page .global-workspace-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0 2px;
}
.page .legacy-dashboard-header { display: none !important; }
.page .pluserp-control-center { background: #f7f9fc; color: #10213b; }
.page .pluserp-dashboard-context-loading .global-workspace-head,
.page .pluserp-dashboard-context-error .global-workspace-head { margin-bottom: 12px; }
@media (max-width: 1100px) {
  .page .global-workspace-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .page .global-workspace-tools { width: 100%; }
  .page .global-workspace-tools .approval-header-controls { justify-content: flex-start; flex-wrap: wrap; }
  .page .global-workspace-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
}

/*
 * Final authenticated workspace frame authority.
 *
 * Approval Workspace is the approved visual reference.  Primary workspaces
 * share one outer gutter, one compact command header, one optional action
 * rail and one content rhythm.  This block intentionally follows every
 * legacy adoption rule so hydrated workspace CSS cannot reintroduce a second
 * inset or a larger title band.
 */
.page:has(> :is(.plus-workspace, .erp-admin-center)) {
  box-sizing: border-box;
  padding: 12px 24px 24px !important;
  gap: 12px !important;
}

.page > :is(.plus-workspace, .erp-admin-center) {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin: 0 !important;
  padding: 0 !important;
  gap: 12px !important;
}

.page .global-workspace-head {
  width: 100%;
  min-height: 52px !important;
  height: 52px;
  align-items: flex-end !important;
  gap: 20px !important;
  margin: 0 !important;
  padding: 0 2px 6px !important;
  border-bottom: 1px solid #e4eaf2 !important;
}

.page .global-workspace-identity,
.page .global-workspace-tools {
  align-self: flex-end;
}

.page .global-workspace-identity {
  flex: 0 1 520px;
  gap: 3px;
}

.page .global-workspace-identity h1 {
  font-size: 21px !important;
  line-height: 24px !important;
}

.page .global-workspace-identity p {
  font-size: 12px !important;
  line-height: 15px !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page .global-workspace-tools {
  flex: 1 1 auto;
  width: auto;
  max-width: 760px;
  min-width: 0;
}

.page .global-workspace-tools .approval-header-controls {
  width: 100%;
  min-height: 43px;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 10px;
}

.page .global-workspace-tools .approval-header-context {
  box-sizing: border-box;
  flex: 0 0 210px;
  width: 210px;
  min-width: 210px;
  max-width: 210px;
  height: 43px;
  min-height: 43px;
  padding: 4px 10px;
}

.page .global-workspace-tools .approval-header-context strong,
.page .global-workspace-tools .approval-header-context select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page .global-workspace-tools .approval-header-user {
  flex: 0 0 164px;
  width: 164px;
  min-width: 164px;
}

/* Optional workspace commands occupy one compact rail without moving title. */
.page .global-workspace-actions {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  margin: 0 !important;
  padding: 0 2px !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
}

/* Some migrated views still emit an inner legacy action wrapper. Flatten it. */
.page .global-workspace-actions > .global-workspace-actions {
  min-height: 0;
  padding: 0 !important;
}

.page :is(.sales-workspace-tools, .purchase-tools, .masters-header-tools, .erp-admin-search) {
  width: 100%;
  min-width: 0 !important;
  max-width: none;
}

.page :is(.sales-workspace-tools, .purchase-tools) {
  display: grid !important;
  grid-template-columns: max-content minmax(260px, 1fr) 48px;
  align-items: center;
}

.page :is(.sales-workspace-tools, .purchase-tools) .sales-search {
  width: 100%;
  min-width: 0;
}

.page .masters-header-tools,
.page .erp-admin-search {
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center !important;
}

.page .masters-header-tools .masters-search,
.page .erp-admin-search label {
  width: min(100%, 420px);
  margin: 0;
}

/* Root grids begin on the same baseline immediately after header/action rail. */
.page :is(.pluserp-dashboard, .approval-workspace-main, .sales-workspace,
  .purchases-workspace, .masters-workspace, .banking-owner-workspace,
  .general-journal-workspace, .coa-workspace, .inventory-workspace,
  .hr-workspace, .reports-workspace, .erp-admin-center) {
  gap: 12px !important;
}

/* Commercial desktop authority: six KPI cards remain one row when space exists. */
@media (min-width: 1440px) {
  .purchases-workspace.plus-workspace :is(.purchase-kpis, .purchase-loading-kpis) {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .page:has(> :is(.plus-workspace, .erp-admin-center)) {
    padding: 10px 16px 20px !important;
  }

  .page .global-workspace-head {
    height: auto;
    min-height: 0 !important;
    align-items: flex-start !important;
    flex-direction: column;
    gap: 10px !important;
  }

  .page .global-workspace-tools {
    align-self: stretch;
    width: 100%;
    max-width: none;
  }

  .page .global-workspace-tools .approval-header-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .page .global-workspace-tools .approval-header-context {
    flex: 1 1 210px;
    width: auto;
    max-width: none;
  }

  .page .global-workspace-actions {
    height: auto;
    min-height: 48px;
    justify-content: flex-start !important;
    flex-wrap: wrap;
  }
}

@media (max-width: 680px) {
  .page .global-workspace-identity p { white-space: normal; }
  .page .global-workspace-tools .approval-header-context {
    flex-basis: 100%;
    width: 100%;
  }
  .page :is(.sales-workspace-tools, .purchase-tools) {
    grid-template-columns: 1fr;
  }
}

/* Approval Workspace compact command header: title, context and user share one visual row. */
.page:has(.approval-workspace) {
  padding-top: 12px;
}

.page .approval-workspace .approval-workspace-head {
  min-height: 58px !important;
  align-items: flex-end !important;
  gap: 20px;
  padding: 0 2px 8px !important;
  border-bottom: 1px solid #e4eaf2 !important;
}

.page .approval-workspace .approval-workspace-head > div:first-child,
.page .approval-workspace .approval-workspace-tools {
  align-self: center;
}

.page .approval-workspace .approval-workspace-head > div:first-child {
  display: grid;
  gap: 3px;
}

.page .approval-workspace .approval-workspace-head p {
  margin: 0 !important;
  font-size: 12px !important;
  line-height: 15px !important;
}

.page .approval-workspace .approval-workspace-tools {
  flex: 1 1 auto;
  max-width: 760px;
  padding-top: 0;
}

.page .approval-workspace .approval-header-context {
  height: 46px;
  min-height: 46px;
  padding: 5px 10px;
}

@media (max-width: 1100px) {
  .page .approval-workspace .approval-workspace-head {
    min-height: 0 !important;
    align-items: flex-start !important;
    flex-direction: column;
    gap: 10px;
  }

  .page .approval-workspace .approval-workspace-tools {
    align-self: stretch;
    width: 100%;
    max-width: none;
  }
}

/*
 * FINAL GLOBAL WORKSPACE GEOMETRY AUTHORITY
 *
 * Approval Workspace is the approved reference.  Keep this block last so
 * hydrated workspace rules cannot restore legacy title bands, gutters or
 * toolbar spacing after the shared header has rendered.
 */
.page:has(> :is(.plus-workspace, .erp-admin-center)) {
  box-sizing: border-box;
  padding: 12px 24px 24px !important;
  gap: 12px !important;
}

.page > :is(.plus-workspace, .erp-admin-center) {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin: 0 !important;
  padding: 2px 24px 20px !important;
  gap: 12px !important;
}

.page .global-workspace-head {
  width: 100%;
  min-height: 52px !important;
  height: 52px;
  align-items: flex-end !important;
  gap: 20px !important;
  margin: 0 !important;
  padding: 0 2px 6px !important;
  border-bottom: 1px solid #e4eaf2 !important;
}

.page .global-workspace-identity,
.page .global-workspace-tools {
  align-self: flex-end;
}

.page .global-workspace-identity {
  flex: 0 1 520px;
  gap: 3px;
}

.page .global-workspace-identity h1 {
  font-size: 21px !important;
  line-height: 24px !important;
}

.page .global-workspace-identity p {
  font-size: 12px !important;
  line-height: 15px !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page .global-workspace-tools {
  flex: 1 1 auto;
  width: auto;
  max-width: 760px;
  min-width: 0;
}

.page .global-workspace-tools .approval-header-controls {
  width: 100%;
  min-height: 43px;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 10px;
}

.page .global-workspace-tools .approval-header-context {
  box-sizing: border-box;
  flex: 0 0 210px;
  width: 210px;
  min-width: 210px;
  max-width: 210px;
  height: 43px;
  min-height: 43px;
  padding: 4px 10px;
}

.page .global-workspace-tools .approval-header-context strong,
.page .global-workspace-tools .approval-header-context select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page .global-workspace-tools .approval-header-user {
  flex: 0 0 164px;
  width: 164px;
  min-width: 164px;
}

.page .global-workspace-actions {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  margin: 0 !important;
  padding: 0 2px !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
}

.page .global-workspace-actions > .global-workspace-actions {
  min-height: 0;
  padding: 0 !important;
}

.page :is(.sales-workspace-tools, .purchase-tools, .masters-header-tools, .erp-admin-search) {
  width: 100%;
  min-width: 0 !important;
  max-width: none;
}

.page :is(.sales-workspace-tools, .purchase-tools) {
  display: grid !important;
  grid-template-columns: max-content minmax(260px, 1fr) 48px;
  align-items: center;
}

.page :is(.sales-workspace-tools, .purchase-tools) .sales-search {
  width: 100%;
  min-width: 0;
}

.page .masters-header-tools,
.page .erp-admin-search {
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center !important;
}

.page .masters-header-tools .masters-search,
.page .erp-admin-search label {
  width: min(100%, 420px);
  margin: 0;
}

.page :is(.pluserp-dashboard, .approval-workspace-main, .sales-workspace,
  .purchases-workspace, .masters-workspace, .banking-owner-workspace,
  .general-journal-workspace, .coa-workspace, .inventory-workspace,
  .hr-workspace, .reports-workspace, .erp-admin-center) {
  gap: 12px !important;
}

@media (min-width: 1440px) {
  .purchases-workspace.plus-workspace :is(.purchase-kpis, .purchase-loading-kpis) {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .page:has(> :is(.plus-workspace, .erp-admin-center)) {
    padding: 10px 16px 20px !important;
  }

  .page > :is(.plus-workspace, .erp-admin-center) {
    padding: 0 !important;
  }

  .page .global-workspace-head {
    height: auto;
    min-height: 0 !important;
    align-items: flex-start !important;
    flex-direction: column;
    gap: 10px !important;
  }

  .page .global-workspace-tools {
    align-self: stretch;
    width: 100%;
    max-width: none;
  }

  .page .global-workspace-tools .approval-header-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .page .global-workspace-tools .approval-header-context {
    flex: 1 1 210px;
    width: auto;
    max-width: none;
  }

  .page .global-workspace-actions {
    height: auto;
    min-height: 48px;
    justify-content: flex-start !important;
    flex-wrap: wrap;
  }
}

@media (max-width: 680px) {
  .page .global-workspace-identity p { white-space: normal; }
  .page .global-workspace-tools .approval-header-context {
    flex-basis: 100%;
    width: 100%;
  }
  .page :is(.sales-workspace-tools, .purchase-tools) {
    grid-template-columns: 1fr;
  }
}

/* Final global header authority: intentionally last to prevent workspace overrides. */
.page .global-workspace-head {
  width:100%; min-height:66px; display:flex; align-items:center; justify-content:space-between;
  gap:24px; padding:4px 2px 10px; border-bottom:1px solid #e4eaf2; box-sizing:border-box;
}
.page .global-workspace-identity{display:grid;gap:3px;min-width:0}
.page .global-workspace-identity h1{margin:0!important;color:#10213b;font-size:21px!important;line-height:1.15!important;font-weight:700!important;letter-spacing:-.01em;white-space:nowrap}
.page .global-workspace-identity p{margin:0!important;color:#30496c;font-size:12px!important;line-height:1.25!important}
.page .global-workspace-tools{flex:1 1 auto;min-width:0}
.page .global-workspace-tools .approval-header-controls{justify-content:flex-end}
.page .global-workspace-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;min-width:0;margin:0;padding:0 2px}
.page .legacy-dashboard-header{display:none!important}
.page .pluserp-control-center{background:#f7f9fc;color:#10213b}
@media(max-width:1100px){
  .page .global-workspace-head{align-items:flex-start;flex-direction:column;gap:10px}
  .page .global-workspace-tools{width:100%}
  .page .global-workspace-tools .approval-header-controls{justify-content:flex-start;flex-wrap:wrap}
  .page .global-workspace-actions{width:100%;flex-wrap:wrap;justify-content:flex-start}
}

/* CRM Dashboard keeps the shared header inside the visible desktop workspace. */
@media(min-width:1101px){
  .content-crm>.page:has(>.crm-dashboard-workspace)>.global-workspace-head{justify-content:flex-start!important;gap:16px!important}
  .content-crm>.page:has(>.crm-dashboard-workspace)>.global-workspace-head>.global-workspace-identity{flex:0 1 360px!important}
  .content-crm>.page:has(>.crm-dashboard-workspace)>.global-workspace-head>.global-workspace-tools{flex:0 1 auto!important;width:auto!important;max-width:none!important}
  .content-crm>.page:has(>.crm-dashboard-workspace) .approval-header-controls{width:auto!important;justify-content:flex-start!important;gap:8px!important}
  .content-crm>.page:has(>.crm-dashboard-workspace) .approval-header-context{flex:0 1 190px!important;width:190px!important;min-width:160px!important;max-width:190px!important}
  .content-crm>.page:has(>.crm-dashboard-workspace) .approval-header-user{flex:0 1 150px!important;width:150px!important;min-width:125px!important}
}

/* Approval header alerts, help and account menus. */
.approval-header-menu-wrap {
  position: relative;
  flex: 0 0 auto;
}
.approval-header-icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #17233a;
  cursor: pointer;
}
.approval-header-icon-button:hover,
.approval-header-icon-button:focus-visible,
.approval-header-user:hover,
.approval-header-user:focus-visible {
  border-color: #cbdcf5;
  background: #f4f8ff;
  outline: none;
}
.approval-header-icon-button .nav-icon { width: 19px; height: 19px; }
.approval-header-user {
  min-width: 164px;
  min-height: 43px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #10213b;
  cursor: pointer;
  text-align: left;
}
.approval-header-user > .nav-icon {
  width: 16px;
  height: 16px;
  margin-left: auto;
  transition: transform 160ms ease;
}
.approval-header-user[aria-expanded="true"] > .nav-icon { transform: rotate(180deg); }
.approval-header-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1200;
  width: 250px;
  padding: 8px;
  border: 1px solid #dbe4ef;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 32px rgba(15, 35, 70, .16);
}
.approval-header-dropdown[hidden] { display: none !important; }
.approval-header-dropdown > strong {
  display: block;
  padding: 7px 9px 9px;
  color: #10213b;
  font-size: 12px;
}
.approval-header-dropdown button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #1d2d46;
  cursor: pointer;
  text-align: left;
}
.approval-header-dropdown button:hover,
.approval-header-dropdown button:focus-visible {
  background: #f1f6ff;
  outline: none;
}
.approval-header-dropdown button > .nav-icon { width: 17px; height: 17px; flex: 0 0 17px; color: #2563eb; }
.approval-header-dropdown button > span { display: grid; gap: 2px; min-width: 0; }
.approval-header-dropdown b { font-size: 11px; line-height: 1.2; }
.approval-header-dropdown small { color: #64748b; font-size: 9px; line-height: 1.25; }
.approval-header-dropdown hr { margin: 6px 4px; border: 0; border-top: 1px solid #e4eaf2; }
.approval-header-dropdown .approval-header-signout { color: #c62828; }
.approval-header-dropdown .approval-header-signout > .nav-icon { color: #dc2626; }
@media (max-width: 1100px) {
  .approval-user-menu-wrap { margin-left: auto; }
}
@media (max-width: 680px) {
  .approval-user-menu-wrap { margin-left: 0; }
  .approval-header-dropdown { left: 0; right: auto; max-width: calc(100vw - 48px); }
}

/*
 * Shared commercial workspace heading contract.
 *
 * The application page already owns the sidebar offset and outer gutter. A
 * second max-width/centering calculation here made headings start at a
 * different horizontal position on wide displays. Every workspace now uses
 * one compact heading band matching Dashboard's blue control header, while
 * Dashboard keeps its blue visual identity.
 */
.page :is(.plus-workspace, .plus-workspace-standardized)
  :is(.masters-workspace-header, .purchase-head, .sales-workspace-head,
      .approval-workspace-head, .banking-command-center, .banking-header,
      .banking-owner-header,
      .gj-header, .coa-header, .inventory-heading, .hr-heading,
      .reports-center-heading, .settings-control-header) {
  box-sizing: border-box;
  width: 100%;
  min-height: 96px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  align-items: flex-start !important;
}

.page :is(.plus-workspace, .plus-workspace-standardized)
  :is(.masters-heading, .purchase-head > div:first-child,
      .sales-workspace-head > div:first-child,
      .approval-workspace-head > div:first-child,
      .banking-command-center > div:first-child,
      .banking-header > div:first-child, .banking-owner-header > div:first-child,
      .gj-header > div:first-child,
      .coa-header > div:first-child, .inventory-heading > div:first-of-type,
      .hr-heading > div:first-of-type,
      .reports-center-heading > div:first-child,
      .settings-control-header > div:first-child) {
  min-width: 0;
  align-self: flex-start;
}

/* Stable heading typography across the commercial workspaces. */
.page :is(.plus-workspace, .plus-workspace-standardized)
  :is(.masters-workspace-header, .purchase-head, .sales-workspace-head,
      .approval-workspace-head, .banking-command-center, .banking-header,
      .banking-owner-header,
      .gj-header, .coa-header, .inventory-heading, .hr-heading,
      .reports-center-heading, .settings-control-header) :is(h1, h2) {
  margin: 0;
  color: var(--color-text-primary);
  font-size: 21px !important;
  font-weight: var(--font-weight-bold) !important;
  line-height: 1 !important;
  letter-spacing: -.01em;
}

.page :is(.plus-workspace, .plus-workspace-standardized)
  :is(.masters-workspace-header, .purchase-head, .sales-workspace-head,
      .approval-workspace-head, .banking-command-center, .banking-header,
      .banking-owner-header,
      .gj-header, .coa-header, .inventory-heading, .hr-heading,
      .reports-center-heading, .settings-control-header) p {
  margin-block: 6px 0 !important;
  color: var(--color-text-secondary);
  font-size: 13px !important;
  font-weight: 400 !important;
  line-height: 18px !important;
}

/* Context belongs to the same predictable third line in every workspace. */
.page :is(.plus-workspace, .plus-workspace-standardized)
  :is(.masters-workspace-header, .purchase-head, .sales-workspace-head,
      .approval-workspace-head, .banking-header, .banking-owner-header,
      .gj-header)
  .tenant-context {
  margin-top: 10px !important;
}

/* The context bootstrap must occupy the same typography before hydration. */
.page .global-context-gate > header h1 {
  margin: 0 !important;
  font-size: 21px !important;
  font-weight: var(--font-weight-bold) !important;
  line-height: 1 !important;
  letter-spacing: -.01em;
}

.page .global-context-gate > header p {
  margin: 6px 0 10px !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  line-height: 18px !important;
}

/* Keep the pre-hydration shell on the same coordinates as the live workspace.
 * Approval and Sales intentionally render an empty gate header owned by their
 * shell, so this contract applies only when the gate renders its own heading. */
.page .global-context-gate:has(> header:not(:empty)) {
  box-sizing: border-box;
  gap: 12px !important;
  padding: 20px 24px !important;
}

.page .global-context-gate > header:not(:empty) {
  box-sizing: border-box;
  width: 100%;
  min-height: 96px !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Header actions share a single top baseline and never move the title. */
.page :is(.plus-workspace, .plus-workspace-standardized)
  :is(.masters-header-tools, .purchase-tools, .sales-workspace-tools,
      .approval-workspace-tools, .banking-header-actions,
      .banking-owner-actions,
      .gj-header-actions, .coa-header-actions, .inventory-heading-actions,
      .hr-heading-actions, .reports-context-badge,
      .settings-control-tools) {
  align-self: flex-start;
  margin-top: 0;
}

/*
 * Hydrated Cash & Banking and Chart of Accounts previously reintroduced their
 * legacy heading geometry through higher-specificity :has() rules. Match that
 * specificity here so the loading and live states keep the same contract.
 */
.page:has(.banking-owner-header) .banking-owner-header,
.page:has(.coa-workspace) .coa-header {
  min-height: 96px !important;
  margin: 0 !important;
  padding: 0 !important;
  align-items: flex-start !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.page:has(.banking-owner-header) .banking-owner-header h1,
.page:has(.coa-workspace) .coa-header h1 {
  margin: 0 !important;
  color: var(--color-text-primary) !important;
  font-family: var(--font-family-sans) !important;
  font-size: 21px !important;
  font-weight: var(--font-weight-bold) !important;
  line-height: 1 !important;
  letter-spacing: -.01em !important;
}

.page:has(.banking-owner-header) .banking-owner-header > div:first-child > p,
.page:has(.coa-workspace) .coa-header > div:first-child > p {
  margin: 6px 0 0 !important;
  color: var(--color-text-secondary) !important;
  font-family: var(--font-family-sans) !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  line-height: 18px !important;
}

.page:has(.banking-owner-header) .banking-owner-actions,
.page:has(.coa-workspace) .coa-header-actions {
  align-self: flex-start !important;
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* Approval Workspace is the approved desktop spacing reference. Cash is
 * rendered directly inside .page, while COA owns a nested workspace wrapper;
 * these offsets therefore reach the same 40px sidebar gutter and 36px top
 * baseline through different containers. */
.page:has(.banking-owner-header) {
  gap: 12px !important;
  padding: 36px 40px 16px !important;
}

.page:has(.coa-workspace) .coa-workspace {
  gap: 12px !important;
  padding: 20px 24px 18px !important;
}

@media (max-width: 1023px) {
  .page:has(.banking-owner-header) {
    padding: 20px 24px 16px !important;
  }

  .page:has(.coa-workspace) .coa-workspace {
    padding: 16px !important;
  }
}

/* These legacy navigation buttons previously consumed a separate title row. */
.inventory-heading > .inventory-back,
.hr-heading > .btn:first-child {
  display: none !important;
}

/* One approved KPI contract: Settings geometry, white surface, semantic icon. */
:is(.masters-kpi-grid, .pluserp-kpi-grid, .sales-kpi-grid, .purchase-kpis,
    .approval-executive-grid, .banking-kpi-grid, .gj-kpis, .coa-kpi-grid,
    .inventory-kpis, .hr-kpis, .reports-metric-grid, .settings-status-strip) {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-3);
  min-width: 0;
  overflow: visible;
}

:is(.plus-card.plus-kpi-card, .masters-kpi, .pluserp-kpi-card,
    .sales-kpi-card, .purchase-kpi, .approval-workspace-kpi, .banking-kpi,
    .gj-kpi, .coa-kpi, .inventory-kpis > article, .hr-kpis > article,
    .reports-kpi-card, .reports-metric-grid > .metric, .settings-status-card) {
  box-sizing: border-box;
  min-width: 0;
  min-height: 138px;
  padding: 18px;
  border: var(--border-standard);
  border-radius: 12px;
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-card);
  color: var(--color-text-primary);
}

:is(.plus-card.plus-kpi-card, .masters-kpi, .pluserp-kpi-card,
    .sales-kpi-card, .purchase-kpi, .approval-workspace-kpi, .banking-kpi,
    .gj-kpi, .coa-kpi, .inventory-kpis > article, .hr-kpis > article,
    .reports-kpi-card, .reports-metric-grid > .metric, .settings-status-card)
  :is(svg, i, .pluserp-kpi-icon, .gj-kpi-icon) {
  flex: 0 0 auto;
}

/*
 * KPI copy must be bounded by the card, otherwise a flex child can grow to
 * its intrinsic currency width and make text measurement report false space.
 */
:is(.plus-card.plus-kpi-card, .masters-kpi, .pluserp-kpi-card,
    .sales-kpi-card, .purchase-kpi, .approval-workspace-kpi, .banking-kpi,
    .gj-kpi, .coa-kpi, .inventory-kpis > article, .hr-kpis > article,
    .reports-kpi-card, .reports-metric-grid > .metric, .settings-status-card,
    .pluserp-health-card, .pluserp-alert-card, .pluserp-activity-card)
  > :is(span, div):last-child {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}

/*
 * Commercial KPI hierarchy: titles and values remain the same size across a
 * row. Currency is visually separated from the complete, unabridged amount.
 */
:is(.plus-card.plus-kpi-card, .masters-kpi, .pluserp-kpi-card,
    .sales-kpi-card, .purchase-kpi, .approval-workspace-kpi, .banking-kpi,
    .gj-kpi, .coa-kpi, .inventory-kpis > article, .hr-kpis > article,
    .reports-kpi-card, .reports-metric-grid > .metric, .settings-status-card,
    .pluserp-health-card, .pluserp-alert-card, .pluserp-activity-card)
  strong {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 4px;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  color: var(--color-text-primary);
  font-size: 18px;
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
  line-height: var(--line-height-tight);
  text-overflow: clip;
  white-space: normal;
}

.workspace-card-currency {
  flex: 0 0 auto;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}

.workspace-card-amount {
  flex: 0 0 auto;
  color: inherit;
  font-size: 18px;
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  white-space: nowrap;
}

.workspace-card-negative,
.workspace-card-negative .workspace-card-currency,
.workspace-card-negative .workspace-card-amount {
  color: var(--color-danger, #dc2626);
}

/* Clear, restrained icon hierarchy for KPI and summary cards. */
:is(.plus-card.plus-kpi-card, .masters-kpi, .pluserp-kpi-card,
    .sales-kpi-card, .purchase-kpi, .approval-workspace-kpi, .banking-kpi,
    .gj-kpi, .coa-kpi, .inventory-kpis > article, .hr-kpis > article,
    .reports-kpi-card, .reports-metric-grid > .metric, .settings-status-card,
    .pluserp-health-card, .pluserp-alert-card, .pluserp-activity-card)
  > :is(span, i):first-child {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: color-mix(in srgb, currentColor 7%, transparent);
  box-shadow: none;
  filter: saturate(1.18) contrast(1.05);
  opacity: 1;
}

:is(.plus-card.plus-kpi-card, .masters-kpi, .pluserp-kpi-card,
    .sales-kpi-card, .purchase-kpi, .approval-workspace-kpi, .banking-kpi,
    .gj-kpi, .coa-kpi, .inventory-kpis > article, .hr-kpis > article,
    .reports-kpi-card, .reports-metric-grid > .metric, .settings-status-card,
    .pluserp-health-card, .pluserp-alert-card, .pluserp-activity-card)
  > :is(span, i):first-child svg {
  width: 23px;
  height: 23px;
  opacity: 1;
  stroke-width: 2;
}

:is(.plus-card.plus-kpi-card, .masters-kpi, .pluserp-kpi-card,
    .sales-kpi-card, .purchase-kpi, .approval-workspace-kpi, .banking-kpi,
    .gj-kpi, .coa-kpi, .inventory-kpis > article, .hr-kpis > article,
    .reports-kpi-card, .reports-metric-grid > .metric, .settings-status-card)
  > svg:first-child {
  box-sizing: border-box;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 9.5px;
  border: 0;
  border-radius: 9px;
  background: color-mix(in srgb, currentColor 7%, transparent);
  box-shadow: none;
  filter: saturate(1.18) contrast(1.05);
  opacity: 1;
  stroke-width: 2;
}

/* A tinted card already supplies the semantic field, so a second tile is noise. */
.workspace-card-tinted > :is(span, i):first-child,
.workspace-card-tinted > svg:first-child {
  background: transparent !important;
  box-shadow: none !important;
}

/* Alerts keep a slightly stronger semantic holder for rapid scanning. */
.pluserp-alert-card > .pluserp-control-icon {
  background: color-mix(in srgb, currentColor 9%, transparent) !important;
  box-shadow: none !important;
}

/* Quick actions are intentionally one visual step stronger than KPI icons. */
:is(.pluserp-quick-action .pluserp-control-icon,
    .sales-action-button > i,
    .masters-action .masters-icon,
    .banking-report-grid button > span,
    .hr-quick button > i) {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  padding: 0;
  border-radius: 12px;
  border: 0;
  box-shadow: none;
  filter: saturate(1.18) contrast(1.05);
  opacity: 1;
}

:is(.pluserp-quick-action .pluserp-control-icon,
    .sales-action-button > i,
    .masters-action .masters-icon,
    .banking-report-grid button > span,
    .hr-quick button > i) svg {
  width: 26px;
  height: 26px;
  opacity: 1;
  stroke-width: 2;
}

.purchase-action > svg:first-child {
  box-sizing: border-box;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  padding: 13px;
  border-radius: 12px;
  border: 0;
  box-shadow: none;
  filter: saturate(1.18) contrast(1.05);
  opacity: 1;
  stroke-width: 2;
}

:is(.plus-card.plus-kpi-card, .masters-kpi, .pluserp-kpi-card,
    .sales-kpi-card, .purchase-kpi, .approval-workspace-kpi, .banking-kpi,
    .gj-kpi, .coa-kpi, .inventory-kpis > article, .hr-kpis > article,
    .reports-kpi-card, .reports-metric-grid > .metric, .settings-status-card,
    .pluserp-health-card, .pluserp-alert-card, .pluserp-activity-card)
  > :is(span, div):last-child > :is(span, small):first-child {
  display: -webkit-box;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 600;
  line-height: 18px;
  text-overflow: clip;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

:is(.plus-card.plus-kpi-card, .masters-kpi, .pluserp-kpi-card,
    .sales-kpi-card, .purchase-kpi, .approval-workspace-kpi, .banking-kpi,
    .gj-kpi, .coa-kpi, .inventory-kpis > article, .hr-kpis > article,
    .reports-kpi-card, .reports-metric-grid > .metric, .settings-status-card)
  :is(small, em) {
  overflow: visible;
  color: var(--color-text-muted);
  font-size: var(--font-size-secondary);
  font-style: normal;
  line-height: var(--line-height-snug);
  text-overflow: clip;
}

/* Shared commercial surface, control, quick-action, table and state treatment. */
:is(.plus-workspace, .plus-workspace-standardized)
  :is(.purchase-panel, .purchase-card, .sales-quick-panel, .sales-panel,
      .banking-panel, .gj-filters, .gj-register, .coa-filter-card, .coa-register,
      .inventory-filters, .inventory-register, .hr-panel, .reports-filter-panel,
      .reports-section, .settings-section, .settings-health-panel) {
  border-color: var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-subtle);
}

:is(.plus-workspace, .plus-workspace-standardized)
  :is(input, select, textarea, button, summary) {
  font-family: var(--font-family-sans);
}

:is(.plus-workspace, .plus-workspace-standardized)
  :is(input:not([type="checkbox"]):not([type="radio"]), select) {
  min-height: var(--control-height);
  border-color: var(--color-border-strong);
  border-radius: var(--radius-control);
}

:is(.plus-workspace, .plus-workspace-standardized)
  :is(table, .mini-table) {
  font-size: var(--font-size-table);
}

:is(.plus-workspace, .plus-workspace-standardized)
  :is(th) {
  min-height: var(--table-header-height);
  background: var(--color-bg-subtle);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-semibold);
}

/*
 * Purchases carries long, currency-prefixed values. The generic six-column
 * desktop contract leaves less than 200px per card after the application
 * sidebar, so a value can paint outside its content column even though the
 * text itself is not ellipsized. Keep this financial workspace at a maximum
 * of four KPI/action columns and let the existing breakpoints reduce it.
 */
.purchases-workspace.plus-workspace .purchase-kpis,
.purchases-workspace.plus-workspace .purchase-loading-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.purchases-workspace.plus-workspace .purchase-actions,
.purchases-workspace.plus-workspace .purchase-loading-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.purchases-workspace.plus-workspace .purchase-kpi strong {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

:is(.plus-workspace, .plus-workspace-standardized)
  :is(.badge, .status-badge, .inventory-status, .inventory-type) {
  border-radius: var(--radius-pill);
  font-size: var(--font-size-badge);
  font-weight: var(--font-weight-semibold);
}

/* Sales was the known truncation regression. Keep six authoritative cards in one row. */
.sales-workspace.plus-workspace .sales-kpi-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.sales-workspace.plus-workspace .sales-kpi-card {
  min-height: 138px;
  padding: 18px;
}

.sales-workspace.plus-workspace .sales-kpi-card :is(strong, .sales-kpi-value) {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

@media (max-width: 1439px) {
  :is(.masters-kpi-grid, .pluserp-kpi-grid, .sales-kpi-grid, .purchase-kpis,
      .approval-executive-grid, .banking-kpi-grid, .gj-kpis, .coa-kpi-grid,
      .inventory-kpis, .hr-kpis, .reports-metric-grid, .settings-status-strip) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .sales-workspace.plus-workspace .sales-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .purchases-workspace.plus-workspace :is(.purchase-kpis, .purchase-loading-kpis, .purchase-actions, .purchase-loading-actions) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1023px) {
  .page :is(.plus-workspace, .plus-workspace-standardized)
    :is(.masters-workspace-header, .purchase-head, .sales-workspace-head,
        .approval-workspace-head, .banking-command-center, .banking-header,
        .banking-owner-header,
        .gj-header, .coa-header, .inventory-heading, .hr-heading,
        .reports-center-heading, .settings-control-header) {
    min-height: auto !important;
  }

  :is(.masters-kpi-grid, .pluserp-kpi-grid, .sales-kpi-grid, .purchase-kpis,
      .approval-executive-grid, .banking-kpi-grid, .gj-kpis, .coa-kpi-grid,
      .inventory-kpis, .hr-kpis, .reports-metric-grid, .settings-status-strip) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sales-workspace.plus-workspace .sales-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .purchases-workspace.plus-workspace :is(.purchase-kpis, .purchase-loading-kpis, .purchase-actions, .purchase-loading-actions) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .page :is(.plus-workspace, .plus-workspace-standardized)
    :is(.masters-workspace-header, .purchase-head, .sales-workspace-head,
        .approval-workspace-head, .banking-command-center, .banking-header,
        .banking-owner-header,
        .gj-header, .coa-header, .inventory-heading, .hr-heading,
        .reports-center-heading, .settings-control-header) :is(h1, h2) {
    font-size: 21px !important;
  }
}

@media (max-width: 479px) {
  :is(.masters-kpi-grid, .pluserp-kpi-grid, .sales-kpi-grid, .purchase-kpis,
      .approval-executive-grid, .banking-kpi-grid, .gj-kpis, .coa-kpi-grid,
      .inventory-kpis, .hr-kpis, .reports-metric-grid, .settings-status-strip) {
    grid-template-columns: 1fr;
  }
  .sales-workspace.plus-workspace .sales-kpi-grid { grid-template-columns: 1fr; }
  .purchases-workspace.plus-workspace :is(.purchase-kpis, .purchase-loading-kpis, .purchase-actions, .purchase-loading-actions) {
    grid-template-columns: 1fr;
  }
  :is(.plus-card.plus-kpi-card, .masters-kpi, .pluserp-kpi-card,
      .sales-kpi-card, .purchase-kpi, .approval-workspace-kpi, .banking-kpi,
      .gj-kpi, .coa-kpi, .inventory-kpis > article, .hr-kpis > article,
      .reports-kpi-card, .reports-metric-grid > .metric, .settings-status-card) {
    min-height: 112px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(.plus-workspace, .plus-workspace-standardized) * {
    scroll-behavior: auto;
  }
}

/* Final Approval Workspace header geometry after the shared workspace contract. */
.page:has(.approval-workspace) { padding-top: 12px; }
.page .approval-workspace { padding: 2px 24px 20px !important; }
.page .approval-workspace .approval-workspace-main { gap: 12px !important; }
.page .approval-workspace .approval-workspace-head {
  min-height: 52px !important;
  align-items: flex-end !important;
  gap: 20px;
  padding: 0 2px 6px !important;
  border-bottom: 1px solid #e4eaf2 !important;
}
.page .approval-workspace .approval-workspace-head > div:first-child,
.page .approval-workspace .approval-workspace-tools { align-self: flex-end; }
.page .approval-workspace .approval-workspace-head > div:first-child { display: grid; gap: 3px; }
.page .approval-workspace .approval-workspace-head p {
  margin: 0 !important;
  font-size: 12px !important;
  line-height: 15px !important;
}
.page .approval-workspace .approval-workspace-tools {
  flex: 1 1 auto;
  max-width: 760px;
  padding-top: 0;
}
.page .approval-workspace .approval-header-context {
  height: 43px;
  min-height: 43px;
  padding: 4px 10px;
}
@media (max-width: 1100px) {
  .page .approval-workspace .approval-workspace-head {
    min-height: 0 !important;
    align-items: flex-start !important;
    flex-direction: column;
    gap: 10px;
  }
  .page .approval-workspace .approval-workspace-tools {
    align-self: stretch;
    width: 100%;
    max-width: none;
  }
}
