/* Canonical UI foundation. Distribute with node scripts/ui/sync-workspace.mjs. */
:root {
  font-size: 16px;
  color-scheme: only light;
  --erp-bg: #f5f7fb;
  --erp-panel: #ffffff;
  --erp-text: #20334c;
  --erp-muted: #596b82;
  --erp-primary: #145ac5;
  --erp-selected: #eaf2ff;
  --erp-border: #e0e7f0;
  --erp-control: #748399;
  --erp-warning: #8c4d05;
  --erp-warning-bg: #fff4e3;
  --erp-danger: #b42318;
  --erp-danger-bg: #fff1f0;
  --erp-success: #246b3d;
  --erp-success-bg: #edf8f0;
  --erp-nav-bg: #182638;
  --erp-nav-text: #f4f7fc;
  --erp-nav-hover: #2b405a;
  --erp-nav-focus: #9bc6ff;
  --erp-topbar-height: 70px;
  --erp-page-inset: 20px;
  --erp-panel-inset: 20px;
  --erp-nested-inset: 16px;
  --erp-card-inset: 24px;
  background: var(--erp-bg);
  --blue: #145ac5;
}
body.erp-ui {
  margin: 0; padding: 0; min-width: 0; max-width: none;
  font: 0.875rem/1.55 "Segoe UI", Arial, sans-serif;
  background: var(--erp-bg); color: var(--erp-text); color-scheme: only light;
}
body.erp-ui *, body.erp-ui *::before, body.erp-ui *::after { box-sizing: border-box; }
body.erp-ui [hidden] { display: none !important; }
body.erp-ui.erp-embedded { padding:var(--erp-page-inset); }
body.erp-ui.erp-embedded .erp-shell-owned { display:none !important; }
body.erp-ui.erp-embedded > header { height:auto; background:transparent; color:var(--erp-text); margin:0 0 20px; padding:0; }
body.erp-ui.erp-embedded > header:not(:has(h1)) { display:none; }
body.erp-ui.erp-embedded > header :is(#logout,#identity) { display:none; }
body.erp-ui.erp-embedded :is(#logout,#signout,#disconnect) { display:none !important; }
body.erp-ui.erp-embedded { --erp-topbar-height:0px; }
@media(max-width:720px){body.erp-ui.erp-embedded{padding:16px}}
body.erp-ui .erp-topbar {
  position: sticky; top: 0; z-index: 40;
  height: auto; min-height: 0; max-height: none;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px 24px; margin: 0; background: var(--erp-panel); color: var(--erp-text);
  border: 0; border-bottom: 1px solid var(--erp-border); border-radius: 0;
}
body.erp-ui .erp-wordmark { font-size: 1rem; font-weight: 700; letter-spacing: .04em; color: var(--erp-primary); }
body.erp-ui .erp-topbar-context { color: var(--erp-muted); }
body.erp-ui .erp-theme-label { margin-left: auto; color: var(--erp-muted); font-size: .75rem; }
body.erp-ui .erp-shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); align-items: stretch; }
body.erp-ui .erp-sidebar {
  position: sticky; top: var(--erp-topbar-height); align-self: start;
  height: calc(100dvh - var(--erp-topbar-height)); min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
  margin: 0; padding: 22px 12px; min-width: 0; border: 0; border-right: 1px solid var(--erp-border);
  border-radius: 0; background: var(--erp-nav-bg); color: var(--erp-nav-text);
}
body.erp-ui .erp-sidebar-title { padding: 8px 12px 12px; font-size: .875rem; color: var(--erp-nav-text); font-weight: 600; }
body.erp-ui .erp-sidebar nav { display: grid; align-content: start; gap: 5px; padding: 4px; margin: 0; border: 0; background: transparent; overflow-y: auto; min-height: 0; overscroll-behavior: contain; scrollbar-gutter: stable; scrollbar-color: #9bc6ff #182638; }
body.erp-ui .erp-sidebar a { display: block; padding: 9px 12px; border-radius: 6px; text-decoration: none; overflow-wrap: anywhere; }
body.erp-ui .erp-sidebar a[aria-current] { border-left: 3px solid var(--erp-nav-focus); padding-left: 9px; }
body.erp-ui .erp-content { min-width: 0; padding: var(--erp-page-inset); }
body.erp-ui .erp-breadcrumb { color: var(--erp-muted); font-size: .75rem; margin: 0 0 12px; }
body.erp-ui main { display: block; max-width: none; width: 100%; min-width: 0; margin: 0; padding: 0; }
body.erp-ui .erp-content > header, body.erp-ui main > header {
  color: var(--erp-text); background: transparent; border: 0; padding: 0 0 20px; margin: 0;
  box-shadow: none; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
}
body.erp-ui .erp-content > header p, body.erp-ui main > header p { color: var(--erp-muted); opacity: 1; }
body.erp-ui h1 { color: var(--erp-text); font-size: 1.75rem; line-height: 1.25; letter-spacing: normal; margin: 0 0 10px; }
body.erp-ui h2 { color: var(--erp-text); font-size: 1.125rem; line-height: 1.4; margin: 0 0 14px; }
body.erp-ui h3 { color: var(--erp-text); font-size: 1rem; margin: 0 0 10px; }
body.erp-ui :is(h1,h2,h3,p,summary,label,dt,dd) { overflow-wrap: anywhere; }
body.erp-ui p { color: inherit; }
body.erp-ui :is(.brand,.eyebrow) { color: var(--erp-primary); }
body.erp-ui .brand { background: transparent; }
body.erp-ui :is(.brand span,.workspace,.optional,.metrics span,.details span) { color: var(--erp-muted); }
body.erp-ui .erp-content > header nav { color: var(--erp-muted); }
body.erp-ui :is(.mark,.containerIcon) { background: var(--erp-selected); color: var(--erp-primary); }
body.erp-ui .erp-content > header > span:not(.status):not(.brand) { color: var(--erp-primary); }
body.erp-ui :is(.muted,.hint,.empty,.subtitle,.intro,.description,.erp-muted,small,.small,.id,.meta) {
  color: var(--erp-muted); opacity: 1;
}
body.erp-ui small, body.erp-ui .small { font-size: .75rem; }
body.erp-ui :is(section,.erp-panel) { min-width: 0; background: var(--erp-panel); color: var(--erp-text); border: 1px solid var(--erp-border); border-radius: 8px; padding: var(--erp-panel-inset); margin-bottom: 20px; }
body.erp-ui section section { padding: var(--erp-nested-inset); }
/* Container spacing only; preserve control sizes and table row density. */
body.erp-ui :where(.ant-card) > .ant-card-body { padding: var(--erp-card-inset); }
body.erp-ui :where(.ant-card) > .ant-card-head { padding-inline: var(--erp-card-inset); }
body.erp-ui .ant-card.ant-card-small > .ant-card-body { padding: 12px; }
body.erp-ui .ant-card.ant-card-small > .ant-card-head { padding-inline: 12px; }
body.erp-ui :is(.layout,.columns,.split,.grid,.erp-grid,.two-column,.workbench) { min-width: 0; }
body.erp-ui :is(.layout,.columns,.split,.grid,.erp-grid,.two-column,.workbench) > * { min-width: 0; }
body.erp-ui .erp-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,240px),1fr)); gap: 16px; }
body.erp-ui :is(.toolbar,.actions,.erp-toolbar) { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
body.erp-ui :is(form,fieldset) { min-width: 0; max-width: 100%; }
body.erp-ui fieldset { border: 1px solid var(--erp-border); border-radius: 6px; margin: 12px 0; padding: 16px; }
body.erp-ui legend { color: var(--erp-text); font-weight: 600; padding: 0 6px; }
body.erp-ui label { color: var(--erp-text); font-size: .875rem; min-width: 0; max-width: 100%; }
body.erp-ui .erp-required-star { display:inline; margin-inline-start:3px; color:#b42318; font-weight:700; }
body.erp-ui .ant-form-item-label > label.ant-form-item-required { display:inline-flex; flex-direction:row; align-items:center; }
body.erp-ui .ant-form-item-label > label.ant-form-item-required::before { content:'*' !important; display:inline-block !important; margin-inline-end:4px; color:#b42318; font-weight:700; }
body.erp-ui :is(input,select,textarea) {
  color: var(--erp-text); background: var(--erp-panel); border: 1px solid var(--erp-control);
  border-radius: 5px; padding: 9px 11px; font: inherit; max-width: 100%; min-width: 0; opacity: 1;
  color-scheme: only light;
}
body.erp-ui :is(input,textarea)::placeholder { color: var(--erp-muted); opacity: 1; }
body.erp-ui :is(input,textarea,select):disabled { color: var(--erp-muted); background: var(--erp-bg); opacity: 1; -webkit-text-fill-color: var(--erp-muted); cursor: not-allowed; }
body.erp-ui :is(input,textarea)[readonly] { background: var(--erp-bg); }
body.erp-ui :is(input,select,textarea)[aria-invalid="true"] { border-color: var(--erp-danger); }
body.erp-ui :is(input[type="checkbox"],input[type="radio"]) { accent-color: var(--erp-primary); width: auto; min-width: auto; }
body.erp-ui select option { background: var(--erp-panel); color: var(--erp-text); }
body.erp-ui textarea { width: 100%; resize: vertical; }
body.erp-ui button, body.erp-ui .button {
  color: #fff; background: var(--erp-primary); border: 1px solid var(--erp-primary); border-radius: 5px;
  padding: 9px 14px; font: inherit; font-weight: 600; max-width: 100%; min-width: 0; white-space: normal;
  overflow-wrap: anywhere; opacity: 1; box-shadow: none; cursor: pointer; text-decoration: none;
}
body.erp-ui button:hover { background: #104ba7; color: #fff; border-color: #104ba7; opacity: 1; }
body.erp-ui button:active { background: #103e85; color: #fff; }
body.erp-ui button :is(small,.muted,.hint,.meta) { color: inherit; }
body.erp-ui :is(button.secondary,button.quiet,button.ghost,button.order,button.item,button.task,button.row,button.record,.erp-secondary) {
  background: var(--erp-panel); color: var(--erp-primary); border-color: var(--erp-control);
}
body.erp-ui :is(button.secondary,button.quiet,button.ghost,button.order,button.item,button.task,button.row,button.record,.erp-secondary):hover {
  background: var(--erp-selected); color: var(--erp-primary);
}
body.erp-ui button.danger { background: var(--erp-danger); border-color: var(--erp-danger); color: #fff; }
body.erp-ui button.done { background: var(--erp-success); border-color: var(--erp-success); color: #fff; }
body.erp-ui button:disabled, body.erp-ui button[aria-disabled="true"] {
  background: var(--erp-bg); color: var(--erp-muted); border-color: var(--erp-control); opacity: 1; cursor: not-allowed;
}
body.erp-ui button[aria-pressed="true"], body.erp-ui button[aria-selected="true"] {
  background: var(--erp-selected); color: var(--erp-primary); border-color: var(--erp-primary); box-shadow: inset 0 -2px var(--erp-primary);
}
body.erp-ui :is(button,input,select,textarea,a,summary,[tabindex]):focus-visible { outline: 3px solid var(--erp-primary); outline-offset: 3px; }
body.erp-ui a { color: var(--erp-primary); }
body.erp-ui a:hover { color: #104ba7; text-decoration: underline; }
body.erp-ui :is(table,.erp-table) { width: 100%; border-collapse: collapse; color: var(--erp-text); font-size: .875rem; }
body.erp-ui :is(th,td) { padding: 12px; border: 0; border-bottom: 1px solid var(--erp-border); vertical-align: top; text-align: left; overflow-wrap: anywhere; }
body.erp-ui th { background: var(--erp-bg); color: var(--erp-muted); font-weight: 600; }
body.erp-ui td { color: var(--erp-text); }
body.erp-ui tbody tr:hover { background: #f0f5fc; }
body.erp-ui tr[aria-selected="true"], body.erp-ui tr.selected { background: var(--erp-selected); color: var(--erp-text); }
body.erp-ui :is(.tablewrap,.table-wrap,.table-scroll,.scroll,.erp-table-wrap) { max-width: 100%; overflow-x: auto; }
body.erp-ui :is(.number,.numeric,.amount,[data-align="number"]) { text-align: right; font-variant-numeric: tabular-nums; }
body.erp-ui :is(.status,.notice,#status,#notice,[role="status"]) { color: var(--erp-text); background: var(--erp-selected); border-radius: 6px; overflow-wrap: anywhere; }
body.erp-ui :is(.warning,.unknown,.pending) { background: var(--erp-warning-bg); color: var(--erp-warning); opacity: 1; }
body.erp-ui :is(.error,.danger,[role="alert"]) { background: var(--erp-danger-bg); color: var(--erp-danger); opacity: 1; }
body.erp-ui :is(.success,.ok) { background: var(--erp-success-bg); color: var(--erp-success); opacity: 1; }
body.erp-ui :is(.badge,.tag,.pill,.chip) { color: var(--erp-text); background: var(--erp-selected); border-color: var(--erp-border); opacity: 1; }
body.erp-ui details { background: var(--erp-panel); color: var(--erp-text); border: 1px solid var(--erp-border); border-radius: 6px; padding: 14px 16px; margin: 12px 0; min-width: 0; }
body.erp-ui summary { color: var(--erp-text); cursor: pointer; font-weight: 600; }
body.erp-ui details[open] > summary { margin-bottom: 14px; }
body.erp-ui details.erp-diagnostics { border-style: dashed; background: var(--erp-bg); }
body.erp-ui :is(pre,code) { color: var(--erp-text); background: var(--erp-bg); overflow-wrap: anywhere; }
body.erp-ui pre { white-space: pre-wrap; padding: 14px; max-width: 100%; border: 1px solid var(--erp-border); border-radius: 6px; }
body.erp-ui dialog { background: var(--erp-panel); color: var(--erp-text); border: 1px solid var(--erp-control); border-radius: 8px; max-width: calc(100% - 32px); }
body.erp-ui dialog::backdrop { background: rgb(32 51 76 / .4); }
body.erp-ui .erp-signin { width: min(440px,calc(100% - 32px)); padding: 24px; }
body.erp-ui .erp-signin form { display: grid; gap: 14px; }
body.erp-ui .erp-signin input { display: block; width: 100%; margin-top: 5px; }
body.erp-ui .erp-record-fields { display: grid; grid-template-columns: minmax(110px,1fr) minmax(0,2fr); gap: 8px 16px; margin: 0; }
body.erp-ui .erp-record-fields dt { color: var(--erp-muted); font-weight: 500; }
body.erp-ui .erp-record-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
body.erp-ui .erp-record-fields .erp-record-fields { display: block; }
body.erp-ui .erp-record-fields .erp-record-fields dd { margin: 3px 0 12px; }
body.erp-ui .erp-record-fields ul { margin: 0; padding-left: 18px; min-width: 0; }
body.erp-ui .erp-record-list { margin: 0; padding-left: 20px; }
body.erp-ui #count { color: var(--erp-primary); background: var(--erp-selected); }
body.erp-ui footer { background: transparent; color: var(--erp-muted); border-top: 1px solid var(--erp-border); padding: 16px 0; margin-top: 24px; font-size: .75rem; }
body.erp-ui .erp-skip { position: absolute; top: -100px; left: 16px; z-index: 100; padding: 10px 14px; background: var(--erp-panel); color: var(--erp-primary); border: 2px solid var(--erp-primary); }
body.erp-ui .erp-skip:focus { top: 12px; }
body.erp-ui.erp-external .erp-shell { display: block; }
body.erp-ui.erp-external .erp-content { max-width: 1200px; margin: auto; }
@media (max-width: 1000px) {
  body.erp-ui .erp-shell { grid-template-columns: 170px minmax(0,1fr); }
  body.erp-ui .erp-content { padding: 18px; }
  body.erp-ui :is(.layout,.columns,.split,.two-column,.workbench) { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 720px) {
  body.erp-ui .erp-record-fields { grid-template-columns: minmax(0,1fr); }
  body.erp-ui .erp-record-fields dd { margin-bottom: 12px; }
  body.erp-ui .erp-shell { display: block; }
  body.erp-ui .erp-topbar { padding: 14px 16px; gap: 8px 14px; }
  body.erp-ui .erp-theme-label { margin-left: 0; }
  body.erp-ui .erp-sidebar { border-right: 0; border-bottom: 1px solid var(--erp-border); padding: 10px 12px; }
  body.erp-ui .erp-sidebar-title { padding: 0 4px 6px; }
  body.erp-ui .erp-sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  body.erp-ui .erp-sidebar a { padding: 7px 9px; }
  body.erp-ui .erp-content { padding: 16px; }
  body.erp-ui :is(section,.erp-panel) { padding: 16px; }
  body.erp-ui :is(.grid,.fields,.form-grid,.erp-grid,.metrics,.stats,.summary-grid) { grid-template-columns: minmax(0,1fr); }
  body.erp-ui :is(input,select,textarea) { font-size: 1rem; width: 100%; }
  body.erp-ui :is(input[type="checkbox"],input[type="radio"]) { width: auto; }
  body.erp-ui :is(form,label) { max-width: 100%; min-width: 0; }
  body.erp-ui h1 { font-size: 1.5rem; }
}
@media (pointer: coarse) { body.erp-ui :is(button,select,summary) { min-height: 44px; } }
/* Shared navigation overrides page-level button styles in every interaction state. */
body.erp-ui .erp-sidebar :is(a,button) { color: var(--erp-nav-text); background: transparent; border: 1px solid transparent; text-align: left; font-weight: 500; text-decoration: none; min-height: 44px; margin: 0; }
body.erp-ui .erp-sidebar :is(a,button):is(:hover,:active,[aria-current]) { color: var(--erp-nav-text); background: var(--erp-nav-hover); }
body.erp-ui .erp-sidebar :is(a,button)[aria-current] { border-left: 3px solid var(--erp-nav-focus); }
body.erp-ui .erp-sidebar :is(a,button):focus-visible { outline: 3px solid var(--erp-nav-focus); outline-offset: -3px; }
body.erp-ui .erp-menu-drill { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 9px 12px; }
body.erp-ui .erp-menu-chevron { color: inherit; font-size: 1.25rem; }
body.erp-ui .erp-menu-header { flex: 0 0 auto; }
body.erp-ui .erp-menu-back { width: 100%; }
body.erp-ui .erp-menu-toggle { display: none; }
body.erp-ui .erp-company-select { width: auto; max-width: min(360px,100%); text-overflow: ellipsis; margin: 0; }
body.erp-ui .erp-company-note { display: none; }
body.erp-ui :is(main,section)[id] { scroll-margin-top: calc(var(--erp-topbar-height) + 16px); }
@media (max-width: 720px) {
  body.erp-ui .erp-menu-toggle { display: block; }
  body.erp-ui .erp-sidebar { display: none; position: fixed; top: var(--erp-topbar-height); left: 0; z-index: 30; width: min(300px,100%); height: calc(100dvh - var(--erp-topbar-height)); border: 0; }
  body.erp-ui.erp-menu-open .erp-sidebar { display: flex; }
  body.erp-ui .erp-sidebar nav { display: grid; }
  body.erp-ui .erp-topbar-context { display: none; }
  body.erp-ui .erp-company-select { flex: 1 1 160px; width: auto; }
  body.erp-ui .erp-theme-label { display: none; }
}
@media (prefers-reduced-motion: reduce) { body.erp-ui * { scroll-behavior: auto !important; transition: none !important; } }
@media (forced-colors: active) {
  :root { --erp-nav-bg: Canvas; --erp-nav-text: CanvasText; --erp-nav-hover: Canvas; --erp-nav-focus: Highlight; }
  :root { --erp-bg: Canvas; --erp-panel: Canvas; --erp-text: CanvasText; --erp-muted: CanvasText; --erp-primary: LinkText; --erp-selected: Canvas; --erp-border: CanvasText; --erp-control: ButtonText; --erp-warning: CanvasText; --erp-warning-bg: Canvas; --erp-danger: CanvasText; --erp-danger-bg: Canvas; --erp-success: CanvasText; --erp-success-bg: Canvas; }
  body.erp-ui :is(button,.button) { color: ButtonText; background: ButtonFace; border-color: ButtonText; }
  body.erp-ui :is(button:disabled,input:disabled,select:disabled,textarea:disabled) { color: GrayText; -webkit-text-fill-color: GrayText; border-style: dashed; }
  body.erp-ui :is(button,input,select,textarea,a,summary):focus-visible { outline-color: Highlight; }
  body.erp-ui :is(button[aria-pressed="true"],button[aria-selected="true"],tr[aria-selected="true"],tr.selected) { outline: 2px solid Highlight; }
}

/* Keep native field padding out of Ant Design's search input (v5 and v6). */
body .ant-select input:is(.ant-select-input,.ant-select-selection-search-input) {
  margin:0!important;padding:0!important;border:0!important;border-radius:0!important;
  background:transparent!important;box-shadow:none!important;min-height:0!important;
  font:inherit!important;line-height:inherit!important;vertical-align:middle;
}
body .ant-select-single .ant-select-content,
body .ant-select-single .ant-select-selector { align-items:center; }
body .ant-select-single .ant-select-selection-search { display:flex;align-items:center; }
body .ant-select-single input:is(.ant-select-input,.ant-select-selection-search-input) { height:100%!important; }
body .ant-select-multiple input:is(.ant-select-input,.ant-select-selection-search-input) { height:auto!important; }
@media(forced-colors:active) {
  .erp-file-drop.is-dragging .ant-upload-drag { outline:3px solid Highlight!important; }
}

select[data-document-upload],select[data-document-upload] + :is(.logistics-control,.equipment-business-select,.processing-business-select) {display:none!important}

/* Upload fields stay together; tall attachments do not stretch information rows. */
.erp-upload-field,.document-controls,.erp-upload-fields,.erp-upload-attachments{min-width:0;width:100%;align-self:start}
.erp-upload-field>label{margin-bottom:0}
.erp-upload-layout{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);gap:16px 24px;align-items:start}
.erp-upload-fields{display:flex;flex-direction:column;gap:12px}
.erp-upload-layout>.erp-upload-actions,.erp-upload-layout>button,.erp-upload-layout>.logistics-control{grid-column:1/-1;justify-self:start}
.erp-document-upload .ant-upload-wrapper,.erp-document-upload .ant-upload-drag{width:100%;min-width:0}
.erp-document-upload>p{font-size:13px;line-height:1.5;margin:8px 0 0}
.erp-upload-attachments .ant-form-item{margin-bottom:12px}

.erp-upload-field input[type="file"]{position:absolute!important;width:1px!important;height:1px!important;clip-path:inset(50%)!important;padding:0!important;margin:0!important}
.erp-upload-layout .erp-grid,.erp-upload-layout .grid{align-items:start}
