/* Final visual contract: approval is the submitted launch document plus approval history/actions. */
:root {
  --flow-reference-page-max-width: 1320px;
  --flow-reference-font-size: 13px;
  --flow-reference-row-height: 28px;
  --flow-reference-label-width: 132px;
  --flow-reference-border: #d8dde6;
  --flow-reference-field: #f4f6f9;
  --flow-reference-section: #f2f2f2;
  --flow-reference-canvas: #eef1f5;
  --flow-reference-text: #1f2329;
  --flow-reference-muted: #7f8792;
  --flow-reference-blue: #168cff;
  --flow-document-max-width: var(--flow-reference-page-max-width);
  --flow-document-font-size: var(--flow-reference-font-size);
  --flow-document-row-height: var(--flow-reference-row-height);
  --flow-document-label-width: var(--flow-reference-label-width);
  --approval-reference-max-width: var(--flow-reference-page-max-width);
  --approval-reference-width: var(--flow-reference-page-max-width);
  --approval-reference-font-size: var(--flow-reference-font-size);
  --approval-reference-row-height: var(--flow-reference-row-height);
}

body[data-ui-theme="macos-workspace-v3"] :is(.flow-form.flow-unified-document, .flow-submitted-document),
body[data-ui-theme="macos-workspace-v3"] :is(.flow-form.flow-unified-document, .flow-submitted-document) * {
  box-sizing: border-box !important;
  letter-spacing: 0 !important;
}

body[data-ui-theme="macos-workspace-v3"] :is(.flow-form.flow-unified-document, .flow-submitted-document) {
  color: var(--flow-reference-text) !important;
  background: #fff !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  font-family: Arial, "Microsoft YaHei", "Source Han Sans SC", sans-serif !important;
  font-size: var(--flow-reference-font-size) !important;
  line-height: 1.35 !important;
}

/* The launch document and submitted document use exactly the same title geometry. */
body[data-ui-theme="macos-workspace-v3"] .flow-form.flow-unified-document .flow-document-heading h3,
body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode > .flow-record-preview-head .flow-approval-title-block strong {
  margin: 0 !important;
  color: #16191d !important;
  font-family: SimSun, "Songti SC", serif !important;
  font-size: 19px !important;
  font-weight: 400 !important;
  line-height: 28px !important;
  text-align: center !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-form.flow-unified-document .flow-document-head {
  padding: 12px 12px 0 !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-form.flow-unified-document .flow-document-heading h3 {
  min-height: 32px !important;
  margin-bottom: 8px !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode > .flow-record-preview-head {
  min-height: 48px !important;
  padding: 8px 12px 4px !important;
  grid-template-columns: 1fr minmax(0, 2fr) 1fr !important;
  align-items: start !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode > .flow-record-preview-head .flow-approval-title-block {
  align-self: end !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode > .flow-record-preview-head .flow-reference-document-number {
  align-self: start !important;
  padding: 0 !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode > .flow-record-preview-head .flow-record-document-number {
  color: var(--flow-reference-muted) !important;
  font-size: 12px !important;
  font-weight: 400 !important;
  line-height: 18px !important;
}

/* Both modes share the same three-column application grid. */
body[data-ui-theme="macos-workspace-v3"] .flow-form.flow-unified-document .flow-reference-meta-grid,
body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-reference-meta-grid,
body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-reference-primary-grid {
  width: 100% !important;
  margin: 0 !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 0 !important;
  border-top: 1px solid var(--flow-reference-border) !important;
  border-left: 1px solid var(--flow-reference-border) !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-form.flow-unified-document .flow-reference-meta-grid > div,
body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document :is(.flow-reference-meta-grid, .flow-reference-primary-grid) > div {
  min-width: 0 !important;
  min-height: var(--flow-reference-row-height) !important;
  display: grid !important;
  grid-template-columns: var(--flow-reference-label-width) minmax(0, 1fr) !important;
  border-right: 1px solid var(--flow-reference-border) !important;
  border-bottom: 1px solid var(--flow-reference-border) !important;
}

body[data-ui-theme="macos-workspace-v3"] :is(.flow-form.flow-unified-document, .flow-submitted-document) :is(.flow-reference-meta-grid, .flow-reference-primary-grid) :is(dt, dd) {
  min-width: 0 !important;
  min-height: calc(var(--flow-reference-row-height) - 1px) !important;
  margin: 0 !important;
  padding: 3px 7px !important;
  display: flex !important;
  align-items: center !important;
  color: var(--flow-reference-text) !important;
  border: 0 !important;
  border-radius: 0 !important;
  font-size: var(--flow-reference-font-size) !important;
  font-weight: 400 !important;
  line-height: 18px !important;
}

body[data-ui-theme="macos-workspace-v3"] :is(.flow-form.flow-unified-document, .flow-submitted-document) :is(.flow-reference-meta-grid, .flow-reference-primary-grid) dt {
  justify-content: flex-end !important;
  text-align: right !important;
  background: #fff !important;
  border-right: 1px solid var(--flow-reference-border) !important;
  overflow-wrap: anywhere !important;
}

body[data-ui-theme="macos-workspace-v3"] :is(.flow-form.flow-unified-document, .flow-submitted-document) :is(.flow-reference-meta-grid, .flow-reference-primary-grid) dd {
  overflow: hidden !important;
  background: var(--flow-reference-field) !important;
  text-align: left !important;
  text-overflow: ellipsis !important;
  overflow-wrap: anywhere !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-form.flow-unified-document .form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-reference-primary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-reference-primary-grid > .is-span-2 {
  grid-column: span 2 !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-reference-primary-grid > .is-span-3 {
  grid-column: 1 / -1 !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document-body {
  width: 100% !important;
  margin: 0 !important;
  padding: 0 12px 12px !important;
  background: #fff !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode .flow-submitted-document .flow-reference-approval-document {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-approval-content-section {
  margin: 6px 0 0 !important;
  border: 1px solid var(--flow-reference-border) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-approval-content-section > header {
  min-height: 32px !important;
  padding: 5px 8px !important;
  background: var(--flow-reference-section) !important;
  border-bottom: 1px solid var(--flow-reference-border) !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-reference-record-tabs {
  min-height: 38px !important;
  margin-top: 8px !important;
  padding: 0 10px !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-reference-record-log-layout {
  min-height: 0 !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  background: #fff !important;
  border-bottom: 1px solid var(--flow-reference-border) !important;
}

body[data-ui-theme="macos-workspace-v3"] .flow-reference-approval-toolbar {
  position: sticky !important;
  bottom: 0 !important;
  z-index: 12 !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: var(--flow-reference-page-max-width) !important;
  margin: 0 auto !important;
  background: #fff !important;
  border-top: 1px solid var(--flow-reference-border) !important;
  border-radius: 0 !important;
}

@media (min-width: 761px) {
  body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) .erp-flow-launch-dialog-body.is-form {
    display: block !important;
    padding: 0 12px !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
  }

  body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) .erp-flow-launch-dialog-form {
    width: 100% !important;
    min-width: 0 !important;
    max-width: var(--flow-reference-page-max-width) !important;
    margin: 0 auto !important;
  }

  body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) form.flow-form.flow-unified-document {
    width: 100% !important;
    min-width: 0 !important;
    max-width: var(--flow-reference-page-max-width) !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode {
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode > :is(.flow-reference-business-tabs, .flow-record-preview-head),
  body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode .flow-record-preview-main {
    width: 100% !important;
    min-width: 0 !important;
    max-width: var(--flow-reference-page-max-width) !important;
    container: approval-flow-document / inline-size !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode .flow-record-preview-layout {
    min-width: 0 !important;
    overflow-x: visible !important;
    overflow-y: auto !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode .flow-submitted-document {
    width: 100% !important;
    min-width: 0 !important;
    max-width: var(--flow-reference-page-max-width) !important;
  }
}

@container approval-flow-document (max-width: 1080px) {
  body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document :is(.flow-reference-meta-grid, .flow-reference-primary-grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-reference-primary-grid > :is(.is-span-2, .is-span-3) {
    grid-column: 1 / -1 !important;
  }
}

@container approval-flow-document (max-width: 700px) {
  body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document :is(.flow-reference-meta-grid, .flow-reference-primary-grid) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (min-width: 761px) and (max-width: 1180px) {
  body[data-ui-theme="macos-workspace-v3"] .flow-form.flow-unified-document :is(.flow-reference-meta-grid, .form-grid),
  body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document :is(.flow-reference-meta-grid, .flow-reference-primary-grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-reference-primary-grid > :is(.is-span-2, .is-span-3) {
    grid-column: 1 / -1 !important;
  }
}

@media (max-width: 760px) {
  :root {
    --flow-reference-label-width: 112px;
  }

  body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) .erp-flow-launch-dialog-body.is-form {
    padding: 0 !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode > .flow-record-preview-head {
    min-height: 64px !important;
    padding: 6px 12px 4px !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: 32px 20px !important;
    align-items: center !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode > .flow-record-preview-head .flow-preview-status-zone {
    display: none !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode > .flow-record-preview-head .flow-approval-title-block {
    grid-column: 1 !important;
    grid-row: 1 !important;
    align-self: center !important;
    justify-self: stretch !important;
    text-align: center !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-approval-mode > .flow-record-preview-head .flow-reference-document-number {
    grid-column: 1 !important;
    grid-row: 2 !important;
    align-self: center !important;
    justify-self: end !important;
    min-width: 0 !important;
    text-align: right !important;
  }

  body[data-ui-theme="macos-workspace-v3"] :is(.flow-form.flow-unified-document, .flow-submitted-document) {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-form.flow-unified-document .flow-reference-meta-grid,
  body[data-ui-theme="macos-workspace-v3"] .flow-form.flow-unified-document .form-grid,
  body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document :is(.flow-reference-meta-grid, .flow-reference-primary-grid, .flow-reference-record-log-layout) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-submitted-document .flow-reference-primary-grid > :is(.is-span-2, .is-span-3) {
    grid-column: 1 !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-reference-approval-toolbar {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }
}

@media print {
  body[data-ui-theme="macos-workspace-v3"] :is(.flow-form.flow-unified-document, .flow-submitted-document) {
    width: 100% !important;
    min-width: 0 !important;
  }

  body[data-ui-theme="macos-workspace-v3"] .flow-reference-approval-toolbar {
    display: none !important;
  }
}

/* The approval command bar is a dedicated row, never an overlay over document content. */
html body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval,
html body[data-ui-theme="macos-workspace-v3"] .global-overlay-root .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval,
html body[data-ui-theme="macos-workspace-v3"] .erp-main .flow-record-preview-backdrop.is-workspace .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval {
  height: auto !important;
  min-height: 0 !important;
  flex: 1 1 0 !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) auto !important;
  align-content: stretch !important;
  gap: 0 !important;
  padding: 0 !important;
  scroll-padding-bottom: 0 !important;
  overflow: hidden !important;
}

html body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-record-preview-main,
html body[data-ui-theme="macos-workspace-v3"] .global-overlay-root .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-record-preview-main,
html body[data-ui-theme="macos-workspace-v3"] .erp-main .flow-record-preview-backdrop.is-workspace .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-record-preview-main {
  min-height: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
  grid-row: 1 !important;
  align-self: stretch !important;
  overflow: auto !important;
  overscroll-behavior: contain;
}

html body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-reference-approval-toolbar,
html body[data-ui-theme="macos-workspace-v3"] .global-overlay-root .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-reference-approval-toolbar,
html body[data-ui-theme="macos-workspace-v3"] .erp-main .flow-record-preview-backdrop.is-workspace .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-reference-approval-toolbar {
  position: static !important;
  grid-row: 2 !important;
  align-self: stretch !important;
}

@media (max-width: 760px) {
  html body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-reference-approval-toolbar,
  html body[data-ui-theme="macos-workspace-v3"] .global-overlay-root .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-reference-approval-toolbar,
  html body[data-ui-theme="macos-workspace-v3"] .erp-main .flow-record-preview-backdrop.is-workspace .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-reference-approval-toolbar {
    height: auto !important;
    min-height: 106px !important;
    max-height: none !important;
  }

  html body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-reference-approval-toolbar > .flow-approval-actions,
  html body[data-ui-theme="macos-workspace-v3"] .global-overlay-root .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-reference-approval-toolbar > .flow-approval-actions,
  html body[data-ui-theme="macos-workspace-v3"] .erp-main .flow-record-preview-backdrop.is-workspace .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-record-preview-layout.has-approval-workbench.is-stacked-approval > .flow-reference-approval-toolbar > .flow-approval-actions {
    width: 100% !important;
    height: auto !important;
    min-height: 106px !important;
    max-height: none !important;
    padding: 6px 8px !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(2, 44px) !important;
    grid-auto-flow: row !important;
    align-items: center !important;
    gap: 6px !important;
    overflow: visible !important;
  }

  html body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-reference-approval-toolbar > .flow-approval-actions .table-action,
  html body[data-ui-theme="macos-workspace-v3"] .global-overlay-root .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-reference-approval-toolbar > .flow-approval-actions .table-action,
  html body[data-ui-theme="macos-workspace-v3"] .erp-main .flow-record-preview-backdrop.is-workspace .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-reference-approval-toolbar > .flow-approval-actions .table-action {
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding-inline: 8px !important;
    grid-column: auto !important;
    grid-row: auto !important;
    order: 0 !important;
  }

  html body[data-ui-theme="macos-workspace-v3"] .flow-record-preview-panel.is-document-preview.is-approval-mode.is-decision-mode .flow-reference-approval-toolbar > .flow-approval-actions .table-action.primary {
    order: -1 !important;
  }
}

/* Core flow dialog interaction authority 2026-09-06 */
body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) > .erp-flow-launch-dialog-shell {
  min-width: 0 !important;
  min-height: 0 !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  overflow: hidden !important;
}

body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) .erp-flow-launch-dialog-head {
  min-height: 38px !important;
  display: flex !important;
  flex: 0 0 auto !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
}

body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) .erp-flow-launch-dialog-body.is-form {
  min-width: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  grid-row: 2 !important;
  padding: 0 12px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) .erp-flow-launch-dialog-form {
  min-height: 100% !important;
  height: 100% !important;
}

body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) .erp-flow-launch-dialog-form > form#flow-form {
  min-height: 100% !important;
  height: 100% !important;
  display: grid !important;
  grid-template-rows: auto minmax(min-content, 1fr) auto !important;
  align-content: stretch !important;
}

@media (max-width: 760px) {
  body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) .erp-flow-launch-dialog-head {
    min-height: 44px !important;
  }

  body[data-ui-theme="macos-workspace-v3"] #erp-flow-launch-dialog:not(.is-picker) .erp-flow-launch-dialog-body.is-form {
    padding: 0 !important;
  }
}
