/* Workspace colour and appearance for the screen and its printed pages. */
html[data-erp-interface] {
    --ui-ink: #18382e;
    --ui-muted: #465d51;
    --ui-canvas: #eef2ee;
    --ui-panel: #ffffff;
    --ui-divider: #b7c8bc;
    --ui-edge: #546f60;
    --ui-focus: #145b70;
    --ui-action: #195a43;
    --ui-title-band: linear-gradient(108deg, #153e34, #285548);
    --ui-title-rule: #c99b66;
    --ui-section: #e0ece3;
    --ui-section-ink: #1a4035;
    --ui-section-rule: #adc3b5;
    --ui-table-head: #dce9df;
    --ui-table-rule: #bfcec3;
    --ui-table-stripe: #f2f6f2;
    --ui-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --ui-control-size: 16px;
    --ui-control-height: 40px;
    --ui-control-pad: 7px 10px;
    --erp-font: var(--ui-font);
    --erp-ink: var(--ui-ink);
    --erp-muted: var(--ui-muted);
    --erp-line: var(--ui-divider);
    --erp-page: var(--ui-canvas);
}

html[data-erp-interface] body {
    font-family: var(--ui-font);
    font-size: 15px;
    line-height: 1.45;
    color: var(--ui-ink);
}
html[data-erp-interface] body.erp-theme { background-color: var(--ui-canvas); }
html[data-erp-interface] :is(.erp-content-viewport, .orders-workspace, .stage-workspace) {
    background-color: var(--ui-canvas);
}
html[data-erp-interface] :is(.panel, .erp-panel, .orders-panel, .stage-panel, .monthly-panel,
    .payment-panel, .review-panel, .finance-panel, .login-panel) {
    background-color: var(--ui-panel);
    border: 1px solid var(--ui-divider);
    border-radius: 11px;
    box-shadow: 0 2px 4px #193d2e09, 0 7px 20px #17382a0a;
}
html[data-erp-interface] :is(.orders-eyebrow, .stage-eyebrow, .eyebrow) { letter-spacing: .07em; }

/* A semantic header works on new screens and on older pages with a nested brand. */
html[data-erp-interface] :is(header:has(h1, .brand, > div > strong), [data-erp-page-header]):not(:where(aside, dialog, [role="dialog"]) *) {
    background: var(--ui-title-band) !important;
    color: white !important;
    box-shadow: inset 0 -3px var(--ui-title-rule);

    & :is(h1, .brand strong), & > div > strong {
        color: white !important;
    }
    & :is(p, small, .eyebrow, [class$="-eyebrow"], .review-label, .signed-user, .bp-user, #bpState),
    & > div > span:not([class]) {
        color: #e0efe8 !important;
    }
    & a:not(:where(details, [role="menu"]) *) {
        color: white !important;
        background-color: transparent !important;
        text-underline-offset: 3px;
    }
    & a:not(:where(details, [role="menu"]) *):hover { background-color: #355f50 !important; }
    & button:not(:disabled, :where(details, [role="menu"]) *) {
        color: #1a4035;
        background-color: #f5faf6;
        border-color: #9ab1a2;
    }
    & :focus-visible:not(:where(details nav, [role="menu"]) *) { outline-color: #ffda9a !important; }
}
/* The two reference masters and the fitted Client/Vendor form supply their own dimensions. */
html[data-erp-interface] body:not(.erp-presets, .erp-client-vendor) :is(header:has(h1, .brand, > div > strong), [data-erp-page-header]):not(:has(.im-heading), :where(aside, dialog, [role="dialog"]) *) {
    box-sizing: border-box;
    height: auto;
    min-height: 64px;
    padding: 12px clamp(14px, 1.8vw, 28px);
    flex-wrap: wrap;
    & :is(h1, .brand strong), & > div > strong {
        font: 700 clamp(23px, 1.7vw, 31px)/1.16 var(--ui-font);
        letter-spacing: -.025em;
    }
}
/* Standalone entry, sign-in and recovery pages sometimes have only a page heading. */
html[data-erp-interface] body:not(:has(header h1, header .brand, header > div > strong, [data-erp-page-header])) h1:not(:where(dialog, aside, [role="dialog"]) *) {
    padding: 11px clamp(14px, 1.8vw, 28px);
    border-radius: 8px 8px 0 0;
    background: var(--ui-title-band) !important;
    box-shadow: inset 0 -3px var(--ui-title-rule);
    color: white !important;
    font: 700 clamp(23px, 1.7vw, 31px)/1.16 var(--ui-font);
    letter-spacing: -.025em;
}

/* Section titles can stand alone or share a band with the section tools. */
html[data-erp-interface] :is([data-erp-section-heading], .section-heading, .module-section-heading,
    .orders-list-heading, .orders-section-title, .stage-panel-title, .demand-section-heading,
    .spec-review-history-heading, .bp-panel-heading, .cv-grid-heading, .dialog-heading,
    dialog header:has(h2), .list-heading:has(h1)) {
    background: var(--ui-section) !important;
    color: var(--ui-section-ink);
    border-block-end: 1px solid var(--ui-section-rule);
    & :is(h1,h2,h3) { color: var(--ui-section-ink); }
}
html[data-erp-interface] h2:not(:where(aside, [role="alert"], [role="status"], .comparison-alert, .trial-held) *, .stage-result-state, [role="status"], [role="alert"], [aria-live]) {
    color: var(--ui-section-ink);
    background-color: var(--ui-section);
    font-family: var(--ui-font);
    line-height: 1.3;
}
html[data-erp-interface] :is(main, section, article, form, dialog, [role="dialog"], .stage-panel, .report-intro) > h2:not(.stage-result-state, [role], [aria-live], :where([role="alert"], [role="status"], .comparison-alert, .trial-held) *) {
    background: var(--ui-section) !important;
    border-block-end: 1px solid var(--ui-section-rule);
}
html[data-erp-interface] body:not(.erp-client-vendor) :is(main, section, article, form, dialog, [role="dialog"], .stage-panel, .report-intro) > h2:not(.im-list-title, .stage-result-state, [role], [aria-live], :where([role="alert"], [role="status"], .comparison-alert, .trial-held) *) {
    padding: 8px 12px;
    font-size: clamp(18px, 1.15vw, 21px);
    letter-spacing: -.018em;
}
html[data-erp-interface] :is(.section-heading, .module-section-heading, .stage-panel-title) {
    padding: 7px 12px;
}
html[data-erp-interface] .item-workspace > .action-bar:has(> label) {
    align-items: end;
    justify-content: flex-start;
    gap: 14px;
    padding: 12px 18px;
    flex-wrap: wrap;
}
html[data-erp-interface] .item-workspace .panel > .run-grid { padding: 15px 18px; }
html[data-erp-interface] .item-workspace .panel > .run-grid + button { margin: 0 18px 15px; }
html[data-erp-interface] .item-workspace > p { margin: 13px 16px; }

html[data-erp-interface] body :is(label, legend, dt, .bp-field > span:first-child, .field-label) {
    font-family: var(--ui-font);
    font-size: max(14px, .92rem);
    font-weight: 620;
    line-height: 1.35;
}
html[data-erp-interface] :is(.stage-help, .orders-hint, .field-help, .item-help, .dialog-note, .bp-help,
    .run-summary dt, .stage-notes, .item-section-help) {
    font-size: 14px;
    color: var(--ui-muted);
}
html[data-erp-interface] :is(td, .stage-picker, .workspace-find-row) {
    --ui-control-size: 15px;
    --ui-control-height: 36px;
    --ui-control-pad: 5px 8px;
}

/* Field states have the same contrast wherever a module declares its own input styles. */
html[data-erp-interface] body :is(
    input:not([type="hidden"],[type="checkbox"],[type="radio"],[type="range"],[type="color"],[type="file"],[type="submit"],[type="reset"],[type="button"],[type="image"]),
    select, textarea, [role="combobox"], button[aria-haspopup="listbox"], [contenteditable="true"]
) {
    box-sizing: border-box;
    min-width: 0;
    min-height: var(--ui-control-height) !important;
    border: 1.5px solid var(--ui-edge) !important;
    border-radius: 7px;
    padding: var(--ui-control-pad);
    font-family: var(--ui-font) !important;
    font-size: var(--ui-control-size) !important;
    font-weight: 450;
    line-height: 1.35;
    color: #20352a !important;
    background-color: #fff !important;
    box-shadow: inset 0 1px 2px #203a2908;
}
html[data-erp-interface] body :is(input, textarea)::placeholder {
    color: #526457;
    font-family: inherit;
    font-size: inherit;
    opacity: 1;
}
html[data-erp-interface] body textarea {
    min-height: max(72px, var(--ui-control-height)) !important;
    line-height: 1.5;
}
html[data-erp-interface] body :is(input:not([type="checkbox"],[type="radio"]), select, textarea, [role="combobox"]):where([readonly],[aria-readonly="true"],:disabled,[aria-disabled="true"]) {
    border-color: #718275 !important;
    color: #41574a !important;
    -webkit-text-fill-color: #41574a;
    background-color: #e9efe9 !important;
    opacity: 1;
}
html[data-erp-interface] body :is(input, select, textarea, [contenteditable="true"], [role="combobox"]):is([aria-invalid="true"],.invalid,.is-invalid,:user-invalid) {
    border-color: #a32d37 !important;
    background-color: #fff1f0 !important;
}
html[data-erp-interface] body :is(input[type="checkbox"],input[type="radio"]) {
    accent-color: var(--ui-action);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    vertical-align: middle;
}
html[data-erp-interface] body :is(input, select, textarea, button, a, summary, [tabindex], [contenteditable="true"]):focus-visible {
    outline: 3px solid var(--ui-focus) !important;
    outline-offset: 2px;
}
html[data-erp-interface] body :is(input, select, textarea, [role="combobox"]):focus-visible:not([aria-invalid="true"],.invalid,.is-invalid,:user-invalid) {
    border-color: var(--ui-focus) !important;
}

html[data-erp-interface] :is(dialog, [role="dialog"]) {
    border-color: #819b8b;
    border-radius: 12px;
    box-shadow: 0 15px 48px #182d2240;
}
html[data-erp-interface] dialog::backdrop { background-color: #11271e61; }
html[data-erp-interface] :is(.action-bar, .orders-toolbar, .stage-actions, .payment-actions, .review-actions, .monthly-actions, .orders-actions) button {
    min-height: 36px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 7px;
}
html[data-erp-interface] body :is(table, .table-wrap) { font-family: var(--ui-font); }
html[data-erp-interface] table { border-spacing: 0; background-color: var(--ui-panel); }
html[data-erp-interface] body :is(th, .entry-grid th, .list-table th, .item-table th) {
    color: #234232;
    background-color: var(--ui-table-head);
    font-size: 14px;
    font-weight: 680;
    line-height: 1.35;
}
html[data-erp-interface] th button {
    color: inherit;
    font: inherit;
}
html[data-erp-interface] body :is(td, .item-table td, .list-table td) {
    font-size: 15px;
    line-height: 1.4;
}
/* Older module grids often declared only a bottom border. Draw both internal edges. */
html[data-erp-interface] table :is(th, td) {
    border-inline-end: 1px solid var(--ui-table-rule) !important;
    border-block-end: 1px solid var(--ui-table-rule) !important;
}
html[data-erp-interface] thead th {
    background: var(--ui-table-head) !important;
    border-color: #a4bbac !important;
}
html[data-erp-interface] tbody tr:nth-child(even):not([class], [aria-selected="true"], [aria-current], [data-state], :hover, :focus-within) {
    background-color: var(--ui-table-stripe);
    & > td:not([class], [style], [data-state], [data-status]) { background-color: var(--ui-table-stripe); }
}
html[data-erp-interface] :is(.stage-table-scroll, .orders-scroll, .table-wrap, .payment-scroll, .review-table-scroll, .monthly-table-scroll) {
    max-width: 100%;
    overflow-x: auto;
}
html[data-erp-interface] .workspace-sidebar .workspace-menu .workspace-link {
    font-size: 14px;
    line-height: 1.34;
}
html[data-erp-interface] .workspace-sidebar .workspace-nav-heading {
    font-size: 11px;
    color: #cbdbcd;
}
html[data-erp-interface] .workspace-sidebar :is(a, button, input):focus-visible {
    outline-color: #ffcd94 !important;
}
@media (max-width: 800px) {
    html[data-erp-interface] :is(.orders-toolbar, .stage-actions, .monthly-actions, .payment-actions, .review-actions) {
        flex-wrap: wrap;
    }
    html[data-erp-interface] .run-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (forced-colors: active) {
    html[data-erp-interface] body :is(input, select, textarea, [role="combobox"], button[aria-haspopup="listbox"]) {
        border-color: ButtonText !important;
    }
    html[data-erp-interface] body :focus-visible { outline-color: Highlight !important; }
}
