/* Shared document contract. Appearance overrides are owned by grid-appearance.css. */
:root {
  --document-header-bg: #2d2b83;
  --document-header-fg: #ffffff;
  --document-cell-radius: 6px;
  --document-cell-gap: 3px;
}
:is(.document-list-table,.stock-document-line-grid,.instrument-line-grid,.document-entry-grid) {
  border-radius: 10px;
}
:is(.document-list-table,.stock-document-line-grid,.instrument-line-grid,.document-entry-grid) table,
.document-workspace .dw-grid {
  border-collapse: separate;
  border-spacing: var(--document-cell-gap);
}
:is(.document-list-table,.stock-document-line-grid,.instrument-line-grid,.document-entry-grid) :is(th,td),
.document-workspace .dw-grid :is(th,td) {
  border: 1px solid var(--erp-border, #dce4e8);
  border-radius: var(--document-cell-radius);
  background-clip: padding-box;
}
:is(.document-list-table,.stock-document-line-grid,.instrument-line-grid,.document-entry-grid) thead th,
.document-workspace .dw-grid thead th {
  background: var(--document-header-bg);
  color: var(--document-header-fg);
}
:is(.document-list-table,.stock-document-line-grid,.instrument-line-grid,.document-entry-grid) thead th :is(span,b,button,svg),
.document-workspace .dw-grid thead th :is(span,b,button,svg) {
  color: var(--grid-appearance-header-fg, var(--document-header-fg));
}
.document-workspace .dw-grid thead th.dw-grid-pinned {
  background: var(--document-header-bg);
  color: var(--document-header-fg);
}
.document-workspace .dw-lines-panel { border-radius: 10px; }
:is(.stock-document-line-grid,.instrument-line-grid,.document-entry-grid) :is(input,select) {
  border-radius: 5px;
}
:is(.stock-document-line-grid,.instrument-line-grid,.document-entry-grid) [hidden] { display: none !important; }
.document-entry-view-command { display: inline-flex; align-items: center; gap: 6px; }
.document-appearance-form .erp-panel-header { background: var(--document-form-header-bg); color: var(--document-form-header-fg); border-radius: 9px 9px 0 0; }
.document-appearance-form .erp-panel-title { color: inherit; }
.document-appearance-form .grid-appearance-colored :is(input,select,label) { background: var(--grid-appearance-bg) !important; color: var(--grid-appearance-fg) !important; }
.document-appearance-form.document-form-font .money-entry-field :is(input,select,label) { font-size: var(--document-form-font) !important; }
.document-form-view-dialog { box-sizing: border-box; width: min(1050px,calc(100vw - 32px)); max-height: calc(100dvh - 40px); padding: 20px; border: 1px solid var(--erp-border,#dce4e8); border-radius: 16px; background: var(--erp-surface,#fff); color: var(--ink,#1b3159); }
.document-form-view-dialog[open] { display: flex; flex-direction: column; gap: 16px; }
.document-form-view-dialog::backdrop { background: #14234088; }
.document-form-view-dialog h2 { margin: 0; font-size: 20px; }
.document-form-view-body { min-height: 0; overflow: auto; }
.document-form-view-dialog footer { display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }
.document-form-view-dialog footer button:first-child { margin-right: auto; }
/* Master-data grids share the document theme without changing their renderers. */
:is(#productWorkspaceTable,#partnerWorkspaceTable,#quickStockGrid,#quickPartnerTable) {
  border-collapse: separate;
  border-spacing: var(--document-cell-gap);
  border-radius: 10px;
}
:is(#productWorkspaceTable,#partnerWorkspaceTable,#quickStockGrid,#quickPartnerTable) :is(th,td) {
  border: 1px solid var(--erp-border,#dce4e8);
  border-radius: var(--document-cell-radius);
  background-clip: padding-box;
}
:is(#productWorkspaceTable,#partnerWorkspaceTable,#quickStockGrid,#quickPartnerTable) thead tr th:not(.grid-appearance-header-colored) {
  background: var(--document-header-bg);
  color: var(--document-header-fg);
}
#productWorkspaceTable thead tr th.product-workspace-column-group:not(.grid-appearance-header-colored) {
  background: var(--document-header-bg);
  color: var(--document-header-fg);
}
:is(#productWorkspaceTable,#partnerWorkspaceTable,#quickStockGrid,#quickPartnerTable) thead th :is(span,b,button,svg) {
  color: var(--grid-appearance-header-fg,var(--document-header-fg));
}
/* Stick the whole two-row header so larger point sizes cannot overlap rows. */
:is(#productWorkspaceTable,#partnerWorkspaceTable) thead { position: sticky; top: 0; z-index: 12; }
:is(#productWorkspaceTable,#partnerWorkspaceTable) thead tr th { position: relative; top: auto; }
#productWorkspaceTable thead tr :is(th.is-frozen,th.product-workspace-expander-cell) { position: sticky; }
#productWorkspaceTable .product-workspace-expander-cell { left: var(--document-cell-gap); }
#productWorkspaceTable tbody tr:not(.product-workspace-virtual-spacer) td { height: var(--appearance-product-row-height,30px); }
#productWorkspaceTable tbody .standard-status { display: flex; width: max-content; max-width: 100%; }
#partnerWorkspaceTable tbody td { height: 30px; }
#productWorkspaceTable .product-workspace-virtual-spacer td { min-height: 0; border: 0; border-radius: 0; padding: 0; background: transparent; }
:is(#quickStockGrid,#quickPartnerTable) td :is(input,select) { border-radius: 5px; }
.erp-master-list-shell:has(:is(#productWorkspaceTable,#partnerWorkspaceTable)),
.quick-stock-grid-scroll:has(:is(#quickStockGrid,#quickPartnerTable)) { border-radius: 10px; }
.partner-list-view-dialog { width: min(1080px,calc(100vw - 28px)); }
@media print {
  :is(#productWorkspaceTable,#partnerWorkspaceTable,#quickStockGrid,#quickPartnerTable) thead tr th { background: #f0f0f0 !important; color: #000 !important; }
  :is(#productWorkspaceTable,#partnerWorkspaceTable,#quickStockGrid,#quickPartnerTable) thead th :is(span,b,button,svg) { color: #000 !important; }
  :is(#productWorkspaceTable,#partnerWorkspaceTable) thead { position: static; }
  :is(.document-list-table,.stock-document-line-grid,.instrument-line-grid,.document-entry-grid) thead th,
  .document-workspace .dw-grid thead th { background: #f0f0f0 !important; color: #000 !important; }
  :is(.document-list-table,.stock-document-line-grid,.instrument-line-grid,.document-entry-grid) thead th :is(span,b,button,svg),
  .document-workspace .dw-grid thead th :is(span,b,button,svg) { color: #000 !important; }
  .document-entry-view-command { display: none !important; }
}
@media (forced-colors: active) {
  :is(#productWorkspaceTable,#partnerWorkspaceTable,#quickStockGrid,#quickPartnerTable) thead th { forced-color-adjust: auto; }
  :is(.document-list-table,.stock-document-line-grid,.instrument-line-grid,.document-entry-grid) thead th,
  .document-workspace .dw-grid thead th { forced-color-adjust: auto; }
}
/* One header gesture contract for card lists, document lists and detail grids. */
.grid-column-controls thead th.grid-column-movable { padding-left:30px!important; padding-right:16px!important; }
.grid-column-controls thead th { position:relative; }
.grid-column-controls .grid-header-move-handle { position:absolute; left:7px; top:50%; transform:translateY(-50%); font-size:17px!important; line-height:1; width:17px; cursor:grab; user-select:none; touch-action:none; }
.grid-column-controls .grid-header-resize-handle { position:absolute; right:0; top:0; bottom:0; width:9px; cursor:col-resize; touch-action:none; z-index:3; }
.grid-column-controls :is(.grid-header-move-handle,.grid-header-resize-handle):focus-visible { outline:2px solid currentColor; outline-offset:-1px; border-radius:3px; }
.grid-column-controls .grid-column-before { box-shadow:inset 4px 0 #35cccc!important; }
.grid-column-controls .grid-column-after { box-shadow:inset -4px 0 #35cccc!important; }
.grid-column-controls .grid-column-dragging { opacity:.65; }
.grid-column-resizing,.grid-column-resizing * { cursor:col-resize!important; user-select:none!important; }
@media print { .grid-header-move-handle,.grid-header-resize-handle { display:none!important; } .grid-column-controls thead th.grid-column-movable { padding-left:8px!important; } }
/* Keep movement commands inside the table geometry and the user's cell palette. */
:is(.document-list-table,.stock-document-grid) :is(.document-row-actions-heading,.document-row-actions-cell) {
  box-sizing: border-box;
  width: 42px !important;
  min-width: 42px !important;
  max-width: 42px !important;
  padding: 0 !important;
  text-align: center !important;
}
:is(.document-list-table,.stock-document-grid) .document-row-actions-heading { font-size: 0 !important; }
.document-row-actions-heading::before { content: '⇄'; font-size: 20px; line-height: 1; }
:is(.document-list-table,.stock-document-grid) td.document-row-actions-cell {
  display: table-cell;
  position: relative;
}
:is(.document-list-table,.stock-document-grid) .document-row-actions-toggle {
  box-sizing: border-box;
  position: absolute; inset: 0; display: grid; place-items: center;
  width: 100%; height: 100%; min-width: 0; min-height: 0;
  margin: 0; padding: 4px; border: 0; border-radius: inherit;
  background: transparent; color: inherit; cursor: pointer;
}
.document-row-actions-toggle svg { width: 18px; height: 18px; fill: currentColor; }
.document-row-actions-toggle:hover,
.document-row-actions-toggle[aria-expanded="true"] { box-shadow: inset 0 0 0 1px currentColor; }
.document-row-actions-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }
.document-row-actions-menu[popover] {
  position: fixed; inset: auto; margin: 0; box-sizing: border-box;
  width: max-content; min-width: 190px; max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px); overflow: auto; padding: 6px;
  border: 1px solid #c9d5e3; border-radius: 10px;
  background: #fff; color: #1e355c; box-shadow: 0 10px 32px #15284733;
}
.document-row-actions-menu:popover-open { display: grid; gap: 3px; }
/* Every module command uses the menu layout, including generic .button actions. */
.document-row-actions-menu[popover] > button {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  box-sizing: border-box; width: 100%; min-width: 0; min-height: 43px;
  margin: 0; padding: 6px 9px; border: 1px solid #d3dfe7; border-radius: 8px;
  background: transparent; color: inherit; cursor: pointer;
  text-align: left; white-space: normal; font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.35;
}
.document-row-actions-menu[popover] > button:hover,
.document-row-actions-menu[popover] > button:focus-visible { background: #eaf7f6; outline: 2px solid #6aacab; outline-offset: -2px; }
body.dark-mode .document-row-actions-menu,
[data-theme="dark"] .document-row-actions-menu { background: #19273f; color: #e6eefb; border-color: #486179; }
body.dark-mode .document-row-actions-menu[popover] > button,
[data-theme="dark"] .document-row-actions-menu[popover] > button { background: transparent; color: inherit; border-color: #486179; }
body.dark-mode .document-row-actions-menu[popover] > button:is(:hover,:focus-visible),
[data-theme="dark"] .document-row-actions-menu[popover] > button:is(:hover,:focus-visible) { background: #294851; }
@media print { .document-row-actions-heading, .document-row-actions-cell, .document-row-actions-menu { display: none !important; } }
.document-action-input { display: grid; gap: 7px; margin-top: 16px; color: inherit; font-weight: 600; }
.document-action-input input, .document-action-input select {
  box-sizing: border-box; width: 100%; min-height: 40px; padding: 8px 10px;
  border: 1px solid #bacbd6; border-radius: 7px; font: inherit;
}

.dw-reuse-return { padding:10px; display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px; }
.dw-reuse-return p { flex:1; min-width:180px; margin:0; }
/* Corporate document commands: scoped styling preserves transactional handlers. */
.document-command-icon { display:inline-grid; place-items:center; flex:0 0 30px; width:30px; height:30px; border:1px solid #d4e9e9; border-radius:8px; background:#edf8f8; color:#478e92; }
.document-command-icon svg { width:18px; height:18px; }
.document-row-actions-menu[popover] { min-width:270px; max-width:min(340px,calc(100vw - 16px)); padding:0 6px 6px; border-color:#d3dfe7; border-radius:12px; box-shadow:0 12px 36px #182d4b26; }
.document-row-actions-caption { display:flex; justify-content:space-between; align-items:center; gap:14px; margin:0 -6px 5px; padding:12px 14px; border-bottom:1px solid #dce8eb; background:#f2f7f8; color:#20365e; }
.document-row-actions-caption strong { font-size:12px; font-weight:800; }
.document-row-actions-caption small { max-width:140px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10px; color:#66818b; }
.document-row-actions-menu[popover] > button[data-command-group="reuse"] + button[data-command-group="linked"] { margin-top:5px; }
.document-row-actions-menu[popover] > button:disabled { opacity:.48; cursor:not-allowed; }
.app-confirm-dialog.app-confirm-document-reuse { width:min(650px,calc(100vw - 28px)); max-height:calc(100dvh - 28px); border:1px solid #d3e1e8; border-radius:17px; color:#20365e; background:#fff; }
.app-confirm-document-reuse .app-confirm-shell { display:flex; flex-direction:column; padding:0; gap:0; max-height:calc(100dvh - 30px); }
.document-reuse-dialog-heading { display:flex; align-items:center; gap:14px; padding:20px 24px; background:linear-gradient(110deg,#25365d,#4b858b); }
.app-confirm-document-reuse .app-confirm-symbol { width:46px; height:46px; flex:0 0 46px; border:1px solid #ffffff38; border-radius:12px; color:#fff; background:#ffffff18; box-shadow:none; }
.document-reuse-dialog-heading .eyebrow { margin:0 0 5px; font-size:10px; letter-spacing:.14em; color:#c5e6e5; }
.document-reuse-dialog-heading h2 { margin:0; font-size:23px; color:#fff; line-height:1.2; }
.app-confirm-document-reuse .app-confirm-content { min-height:0; overflow:auto; padding:18px 24px 20px; }
.app-confirm-document-reuse .app-confirm-message { margin:0 0 17px; font-size:13px; font-weight:500; line-height:1.6; color:#526679; }
.document-reuse-target-caption { margin:0 0 9px; font-size:12px; font-weight:750; }
.document-reuse-targets { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.document-reuse-target { display:flex; align-items:center; gap:10px; min-height:48px; padding:8px 11px; border:1px solid #d8e2e8; border-radius:10px; background:#fff; color:#243b60; text-align:left; font-family:inherit; font-size:12px; font-weight:600; line-height:1.4; cursor:pointer; }
.document-reuse-target:hover { border-color:#78b4b5; background:#f5fbfb; }
.document-reuse-target[aria-checked="true"] { border-color:#4b9a9d; background:#eaf6f5; box-shadow:inset 3px 0 #4b9a9d; }
.document-reuse-target:focus-visible { outline:2px solid #5b969e; outline-offset:2px; }
.app-confirm-document-reuse .app-confirm-actions { flex:0 0 auto; padding:14px 24px; margin:0; border-top:1px solid #dde7eb; background:#f7fafb; }
.app-confirm-document-reuse .app-confirm-actions .button { min-height:40px; border-radius:9px; font-size:12px; }
.app-confirm-document-reuse .app-confirm-accept { border-color:#4b969a; background:linear-gradient(110deg,#4e9b9e,#3f7f8d); box-shadow:none; }
.app-confirm-document-reuse .app-confirm-accept:disabled { opacity:.45; cursor:not-allowed; }
[data-theme="dark"] .document-row-actions-caption { background:#243950; border-color:#486179; color:#e6eefb; }
[data-theme="dark"] .document-command-icon { background:#294851; border-color:#486179; color:#b6dedd; }
[data-theme="dark"] .app-confirm-dialog.app-confirm-document-reuse { background:#19273f; color:#e6eefb; border-color:#486179; }
[data-theme="dark"] .app-confirm-document-reuse .app-confirm-message { color:#c3d0e2; }
[data-theme="dark"] .document-reuse-target { background:#243950; border-color:#486179; color:#e6eefb; }
[data-theme="dark"] .document-reuse-target[aria-checked="true"] { background:#294851; border-color:#79b4b4; }
[data-theme="dark"] .app-confirm-document-reuse .app-confirm-actions { background:#243950; border-color:#486179; }
@media(max-width:520px) { .document-reuse-dialog-heading { padding:16px; gap:10px; }.document-reuse-dialog-heading h2 { font-size:20px; }.app-confirm-document-reuse .app-confirm-content { padding:16px; }.document-reuse-targets { grid-template-columns:1fr; }.app-confirm-document-reuse .app-confirm-actions { padding:12px 16px; flex-direction:row; }.app-confirm-document-reuse .app-confirm-actions .button { width:auto; min-width:0; flex:1; } }

/* Stock receipt/issue lists share the invoice list's edge-to-edge frame. */
.panel.stock-document-page:is([data-page="stock-receipt"],[data-page="stock-issue"]){padding:0}
/* ERP-wide column captions: fixed heading size, independent of content preferences.
   Only caption text participates; drag/filter/sort icons retain their geometry. */
@media screen {
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table,[role="grid"]) [data-erp-column-heading]:not(.document-row-actions-heading),
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table,[role="grid"]) [data-erp-column-heading]:not(.document-row-actions-heading) .erp-column-heading-caption {
    font-family: var(--ui-font,Arial,sans-serif) !important;
    font-size: 7pt !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
  }
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table,[role="grid"]) .erp-column-heading-caption {
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }
  /* Group and column rows use the same geometry, even with saved content sizes. */
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table,[role="grid"]) :is(thead tr,thead th,thead td,[role="columnheader"]) {
    box-sizing: border-box !important;
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    padding-block: 2px !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table,[role="grid"]) .erp-column-heading-text {
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    flex: 0 1 auto;
  }
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table,[role="grid"]) thead .list-sort-label {
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    height: 20px !important;
    padding-block: 0 !important;
    flex-wrap: nowrap !important;
  }
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table) thead th:has(> .standard-column-filter-button) {
    padding-right: 34px !important;
  }
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table,[role="grid"]) thead :is(button,input,select) {
    box-sizing: border-box !important;
    font-size: 7pt !important;
    line-height: 1.25 !important;
    min-height: 0 !important;
    max-height: 24px !important;
    padding-block: 0 !important;
  }
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table,[role="grid"]) thead :is(.list-sort-indicator,.list-sort-legacy-icon,.command-icon,.grid-column-drag-handle,.grid-header-move-handle) {
    font-size: 12px !important;
    line-height: 1 !important;
  }
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table,[role="grid"]) thead .grid-header-move-handle {
    font-size: 17px !important;
  }
  /* Renderers may turn a previously labelled column into an icon command. */
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table) .document-row-actions-heading {
    font-size: 0 !important;
  }
  :root :is(#productWorkspaceTable,#partnerWorkspaceTable,table) .document-row-actions-heading .erp-column-heading-caption {
    display: none !important;
  }
}
