/* Record windows (web/windows.js): each record in a window of its own, moved by its title bar, resized from any edge or
   corner, minimised to the tray, maximised. */
.erp-win{position:fixed;display:flex;flex-direction:column;min-width:360px;min-height:220px;border:1px solid var(--c-line);border-radius:12px;background:var(--c-surface);
  box-shadow:0 18px 50px rgba(16,24,40,.22),0 2px 6px rgba(16,24,40,.08)}
html.clarity.dark .erp-win{box-shadow:0 18px 50px rgba(0,0,0,.6),0 0 0 1px #343c48}
.erp-win:not(.erp-front){box-shadow:0 8px 24px rgba(16,24,40,.14)}
.erp-win.erp-min{display:none}
.erp-win.erp-max{border-radius:8px}
.erp-win-bar{flex:none;display:flex;align-items:center;gap:10px;height:38px;padding:0 4px 0 12px;border-bottom:1px solid var(--c-line);border-radius:12px 12px 0 0;background:var(--c-raised);cursor:move;user-select:none}
.erp-win.erp-max .erp-win-bar{cursor:default;border-radius:8px 8px 0 0}
.erp-win.erp-front .erp-win-bar{background:var(--c-surface)}
.erp-win-kind{flex:none;padding:2px 8px;border-radius:6px;background:var(--c-accent-soft);color:var(--c-accent-text);font-size:11px;font-weight:700;letter-spacing:.03em;text-transform:uppercase}
.erp-win-title{flex:1;min-width:0;display:flex;align-items:baseline;gap:8px;white-space:nowrap;overflow:hidden}
.erp-win-title b{font-size:13.5px;font-weight:600;color:var(--c-text);overflow:hidden;text-overflow:ellipsis}
.erp-win-title span{font-size:12px;color:var(--c-muted);overflow:hidden;text-overflow:ellipsis}
.erp-win-body{position:relative;flex:1;min-height:0;overflow:hidden;border-radius:0 0 12px 12px;background:var(--c-surface)}
.erp-win-body iframe{display:block;width:100%;height:100%;border:0;background:var(--c-surface);visibility:hidden}
.erp-win.erp-win-ready .erp-win-body iframe{visibility:visible}
.erp-win-loading{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:24px;text-align:center;color:var(--c-muted);font-size:14px;background:var(--c-surface)}
.erp-win.erp-win-ready .erp-win-loading{display:none}
.erp-win-loading.erp-win-failed{color:var(--s-r-fg)}
/* while a window is moved or resized, the records inside windows do not take the mouse */
html.erp-win-busy iframe{pointer-events:none}
html.erp-win-busy,html.erp-win-busy *{user-select:none}

/* the edges and corners that resize: thin strips along the window's border only, whatever other window styles say */
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>.win-h{position:absolute!important;z-index:5;display:block!important;margin:0!important;padding:0!important;border:0!important;
  min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;flex:none!important;background:transparent!important}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>:is(.win-h-n,.win-h-s){left:12px!important;right:12px!important;width:auto!important;height:8px!important;cursor:ns-resize}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>.win-h-n{top:-4px!important;bottom:auto!important}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>.win-h-s{bottom:-4px!important;top:auto!important}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>:is(.win-h-e,.win-h-w){top:12px!important;bottom:12px!important;width:8px!important;height:auto!important;cursor:ew-resize}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>.win-h-e{right:-4px!important;left:auto!important}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>.win-h-w{left:-4px!important;right:auto!important}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>:is(.win-h-ne,.win-h-nw,.win-h-se,.win-h-sw){width:16px!important;height:16px!important}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>.win-h-ne{top:-4px!important;right:-4px!important;bottom:auto!important;left:auto!important;cursor:nesw-resize}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>.win-h-sw{bottom:-4px!important;left:-4px!important;top:auto!important;right:auto!important;cursor:nesw-resize}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>.win-h-nw{top:-4px!important;left:-4px!important;bottom:auto!important;right:auto!important;cursor:nwse-resize}
:is(.erp-win,dialog.erp-window,dialog.erp-movable)>.win-h-se{bottom:-4px!important;right:-4px!important;top:auto!important;left:auto!important;cursor:nwse-resize}
:is(.erp-win,dialog.erp-window).erp-max>.win-h{display:none!important}
/* windows on the main page may clip what sticks out (masters clip the record form), so their strips lie just inside the border */
:is(dialog.erp-window,dialog.erp-movable)>.win-h-n{top:0!important}:is(dialog.erp-window,dialog.erp-movable)>.win-h-s{bottom:0!important}:is(dialog.erp-window,dialog.erp-movable)>.win-h-e{right:0!important}:is(dialog.erp-window,dialog.erp-movable)>.win-h-w{left:0!important}
:is(dialog.erp-window,dialog.erp-movable)>.win-h-ne{top:0!important;right:0!important}:is(dialog.erp-window,dialog.erp-movable)>.win-h-nw{top:0!important;left:0!important}
:is(dialog.erp-window,dialog.erp-movable)>.win-h-se{bottom:0!important;right:0!important}:is(dialog.erp-window,dialog.erp-movable)>.win-h-sw{bottom:0!important;left:0!important}

/* record dialogs opened on the main page (not diverted): the same window behaviour */
html.clarity dialog.erp-window{position:fixed;margin:0!important;inset:auto;max-width:none;max-height:none;overflow:visible;min-width:360px;min-height:220px;
  border:1px solid var(--c-line);border-radius:12px;box-shadow:0 18px 50px rgba(16,24,40,.22),0 2px 6px rgba(16,24,40,.08)}
html.clarity.dark dialog.erp-window{box-shadow:0 18px 50px rgba(0,0,0,.6),0 0 0 1px #343c48}
html.clarity dialog.erp-window.erp-max{border-radius:8px}
html.clarity dialog.erp-window.erp-min{display:none}
html.clarity dialog.erp-window :is(.ow-dialog-head,.dialog-header,.approvals-head){cursor:move;user-select:none}
html.clarity dialog.erp-window.erp-max :is(.ow-dialog-head,.dialog-header,.approvals-head){cursor:default}
html.clarity dialog.erp-window :is(.ow-dialog-head,.dialog-header,.approvals-head) :is(input,select,textarea,button,a){cursor:auto}
html.clarity dialog.erp-window>#editor-content,html.clarity dialog.erp-window>.ow-order-layout{height:100%;overflow:auto}
/* big screens as windows (18 Nov 2026): title bar and footer stay, the body between them scrolls */
html.clarity dialog.erp-window.erp-screen:not(.erp-min){display:flex;flex-direction:column;overflow:hidden}
html.clarity dialog.erp-window.erp-screen>:not(.win-h){flex:0 0 auto;min-height:0}
html.clarity dialog.erp-window.erp-screen>:is(.ow-dialog-body,.approvals-body){flex:1 1 auto;overflow:auto}
html.clarity dialog.erp-window.approvals-dialog{animation:none}

.win-ctrls{display:inline-flex;align-items:center;gap:2px;margin-left:auto;flex:none}
.win-btn{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:0;border-radius:6px;background:transparent;color:var(--c-soft);cursor:pointer}
.win-btn:hover{background:var(--c-hover);color:var(--c-text)}
.win-btn[data-win-close]:hover{background:#dc2626;color:#fff}
.win-btn svg{width:16px;height:16px}
:is(.ow-dialog-head,.dialog-header,.approvals-head) .win-ctrls+:is(.ow-close,[data-pw-close],#close-editor,button){margin-left:2px}
.approvals-head .win-btn{color:#fff}
.approvals-head .win-btn:hover{background:#ffffff2e;color:#fff}

/* the tabs of the open windows, under the top bar */
.win-tabs{flex:0 0 auto;display:flex;gap:4px;align-items:flex-end;min-height:38px;padding:4px 10px 0;border-bottom:1px solid var(--c-line);background:var(--c-side);overflow-x:auto;scrollbar-width:thin}
.win-tabs[hidden]{display:none}
.win-tab{flex:0 1 230px;min-width:120px;display:flex;align-items:center;height:33px;border:1px solid var(--c-line);border-bottom:0;border-radius:8px 8px 0 0;background:var(--c-raised);color:var(--c-soft)}
.win-tab.is-front{background:var(--c-surface);color:var(--c-text);border-color:var(--c-accent-line);box-shadow:inset 0 2px 0 var(--c-accent)}
.win-tab.is-min{opacity:.72}
.win-tab-open{flex:1;min-width:0;display:flex;align-items:center;gap:6px;height:100%;padding:0 4px 0 10px;border:0;background:transparent;color:inherit;font:inherit;font-size:12.5px;text-align:left;cursor:pointer}
.win-tab-open em{flex:none;font-style:normal;font-size:10px;font-weight:700;letter-spacing:.03em;text-transform:uppercase;color:var(--c-accent-text)}
.win-tab-open b{min-width:0;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.win-tab-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;margin-right:4px;padding:0;border:0;border-radius:5px;background:transparent;color:var(--c-muted);cursor:pointer}
.win-tab-close:hover{background:#dc2626;color:#fff}
.win-tab-close svg{width:13px;height:13px}
html.clarity .page-help{z-index:96}

/* inside a window: only the record, filling it */
html.erp-child body{background:var(--c-surface)}
html.erp-child :is(.sidebar,.app-shell,.nav-backdrop,.page-help,#win-tabs,.approvals-bell){display:none!important}
html.erp-child :is(#editor,#ow-order-dialog,#ow-item-dialog,#pw-supplier-dialog,#pw-item-dialog,#pw-po-dialog,#pw-grn-dialog,#pw-indent-dialog,#pw-qc-dialog,#pw-dn-dialog,#pw-stock-dialog,#pw-stockdoc-dialog,#pr-ico-dialog,#pb-bom-dialog,#sfg-item-dialog,#pr-pl-dialog):modal{
  inset:0;margin:0;width:100vw;height:100vh;height:100dvh;max-width:none;max-height:none;border:0;border-radius:0;box-shadow:none}
html.erp-child :is(#editor,#ow-order-dialog,#ow-item-dialog,#pw-supplier-dialog,#pw-item-dialog,#pw-po-dialog,#pw-grn-dialog,#pw-indent-dialog,#pw-qc-dialog,#pw-dn-dialog,#pw-stock-dialog,#pw-stockdoc-dialog,#pr-ico-dialog,#sfg-item-dialog,#pr-pl-dialog)::backdrop{background:transparent}
/* the window's bar already names the record and closes it: the record's own title and close button are not repeated
   (21 Nov 2026: only the record's; a picker or form opened inside the window keeps its title and × and is moved by it) */
html.erp-child :is(#editor,#ow-order-dialog,#ow-item-dialog,#pw-supplier-dialog,#pw-item-dialog,#pw-po-dialog,#pw-grn-dialog,#pw-indent-dialog,#pw-qc-dialog,#pw-dn-dialog,#pw-stock-dialog,#pw-stockdoc-dialog,#pr-ico-dialog,#pb-bom-dialog,#sfg-item-dialog,#pr-pl-dialog) :is(.ow-dialog-head,.dialog-header)>div:first-child:has(>h2){display:none}
html.erp-child :is(#editor,#ow-order-dialog,#ow-item-dialog,#pw-supplier-dialog,#pw-item-dialog,#pw-po-dialog,#pw-grn-dialog,#pw-indent-dialog,#pw-qc-dialog,#pw-dn-dialog,#pw-stock-dialog,#pw-stockdoc-dialog,#pr-ico-dialog,#pb-bom-dialog,#sfg-item-dialog,#pr-pl-dialog) :is(.ow-dialog-head,.dialog-header) :is(.ow-close,[data-pw-close],#close-editor,button[aria-label^="Close"]){display:none}
html.erp-child :is(#editor,#ow-order-dialog,#ow-item-dialog,#pw-supplier-dialog,#pw-item-dialog,#pw-po-dialog,#pw-grn-dialog,#pw-indent-dialog,#pw-qc-dialog,#pw-dn-dialog,#pw-stock-dialog,#pw-stockdoc-dialog,#pr-ico-dialog,#pb-bom-dialog,#sfg-item-dialog,#pr-pl-dialog) :is(.ow-dialog-head,.dialog-header):not(:has(.stage-bar)):not(:has(.ow-actions *:not(.ow-close):not([data-pw-close]))){min-height:0;padding-top:4px;padding-bottom:4px}
/* the side menu, and its pop-out groups, stay above the windows (14 Nov 2026) */
body.nav-flyouts .sidebar:has(.flyout-open){z-index:1000}
/* pop-ups in front of everything (pickers, questions, small forms): moved by the title bar, resized from the edges (21 Nov 2026) */
dialog.erp-movable :is(.ow-dialog-head,.dialog-header,.approvals-head),dialog.erp-movable>header{cursor:move;user-select:none}
dialog.erp-movable :is(.ow-dialog-head,.dialog-header,.approvals-head) :is(input,select,textarea,button,a),dialog.erp-movable>header :is(input,select,textarea,button,a){cursor:auto}
