/* Novel ERP Tables V16.2 - guarded scoped refinement over V16.1.
 * IMPORTANT: no late padding, font, colspan, or min-width modifications on
 * DataTables scrollHead/scrollBody/scrollFoot cells. V14 modified widths after
 * DataTables initialized, which desynchronized headings, body and totals.
 * This stylesheet is presentation only; the original theme defines colors. */
@media screen {
  body[class*="skin-"] .erp8-wrapper {
    --erp15-accent: var(--novel-accent-strong, var(--novel-accent, #6930a0));
    --erp15-border: var(--novel-border, #dfe5ed);
    --erp15-ink: var(--novel-ink, #243148);
    --erp15-surface: var(--novel-card, #fff);
    width: 100%; max-width: 100%; min-width: 0;
    position: relative; clear: both;
  }
  /* One table, not three width-independent scroll clones. */
  body[class*="skin-"] .erp8-wrapper .erp15-viewport {
    display: block; width:100%; max-width:100%;
    overflow-x:auto!important; overflow-y:hidden!important;
    border:1px solid var(--erp15-border); border-radius:6px;
    overscroll-behavior-x:contain;
    scrollbar-width:auto; scrollbar-color:var(--erp15-accent) #e6e8ed;
  }
  body[class*="skin-"] .erp8-wrapper .erp15-viewport > table.erp15-horizontal {
    max-width:none!important;
    border-collapse:collapse!important;
    table-layout:fixed!important;
  }
  body[class*="skin-"] .erp8-wrapper .erp15-viewport > table.erp15-horizontal > thead > tr > th,
  body[class*="skin-"] .erp8-wrapper .erp15-viewport > table.erp15-horizontal > tbody > tr > td,
  body[class*="skin-"] .erp8-wrapper .erp15-viewport > table.erp15-horizontal > tfoot > tr > td {
    box-sizing:border-box!important;vertical-align:middle;
  }
  body[class*="skin-"] .erp8-wrapper .erp15-viewport > table.erp15-horizontal > thead > tr > th {
    white-space:normal!important;overflow-wrap:anywhere;
  }
  body[class*="skin-"] .erp8-wrapper .erp15-viewport > table.erp15-horizontal > tbody > tr > td {
    white-space:normal;overflow-wrap:anywhere;
  }
  /* Existing table-responsive hosts must not create nested conflicting scrollbars. */
  body[class*="skin-"] .table-responsive.erp15-responsive-host {overflow-x:visible!important;overflow-y:visible!important;}
  body[class*="skin-"] .erp8-wrapper .erp15-viewport::-webkit-scrollbar,
  body[class*="skin-"] .erp8-wrapper .dataTables_scrollBody::-webkit-scrollbar {height:12px;width:12px;}
  body[class*="skin-"] .erp8-wrapper .erp15-viewport::-webkit-scrollbar-track,
  body[class*="skin-"] .erp8-wrapper .dataTables_scrollBody::-webkit-scrollbar-track {background:#e6e8ed;border-radius:9px;}
  body[class*="skin-"] .erp8-wrapper .erp15-viewport::-webkit-scrollbar-thumb,
  body[class*="skin-"] .erp8-wrapper .dataTables_scrollBody::-webkit-scrollbar-thumb {background:var(--erp15-accent);border-radius:9px;border:2px solid #e6e8ed;}
  body[class*="skin-"] .erp8-wrapper .erp15-scroll-guide {
    display:flex;gap:7px;align-items:center;justify-content:flex-start;direction:inherit;
    margin:8px 0 7px;flex-wrap:wrap;color:var(--erp15-ink);
  }
  body[class*="skin-"] .erp8-wrapper .erp15-scroll-guide[hidden] {display:none!important;}
  body[class*="skin-"] .erp8-wrapper .erp15-scroll-guide .erp15-arrow {
    border:1px solid var(--erp15-border);border-radius:6px;background:var(--erp15-surface);
    color:var(--erp15-accent);min-width:36px;height:32px;line-height:1;cursor:pointer;
    font-size:14px;font-weight:bold;box-shadow:0 1px 3px rgba(0,0,0,.06);
  }
  body[class*="skin-"] .erp8-wrapper .erp15-scroll-guide .erp15-arrow:hover,
  body[class*="skin-"] .erp8-wrapper .erp15-scroll-guide .erp15-arrow:focus-visible {
    border-color:var(--erp15-accent);outline-offset:2px;
  }
  body[class*="skin-"] .erp8-wrapper .erp15-scroll-hint {font-size:12px;opacity:.85;}
  /* High-contrast summary totals in a single cell grid, not extra rows. */
  body[class*="skin-"] .erp8-wrapper table.erp15-horizontal tfoot > tr > td {
    font-size:12px;font-weight:650;line-height:1.6;
    padding:10px 8px;white-space:normal;
  }
  /* V15.3: headings are labels, not order-switch controls. The original
     initial sorting still runs, but these click affordances are removed. */
  body[class*="skin-"] .erp8-wrapper thead th.sorting,
  body[class*="skin-"] .erp8-wrapper thead th.sorting_asc,
  body[class*="skin-"] .erp8-wrapper thead th.sorting_desc,
  body[class*="skin-"] .erp8-wrapper thead th.sorting_disabled {
    cursor:default!important;background-image:none!important;
  }
  body[class*="skin-"] .erp8-wrapper thead th.sorting:before,
  body[class*="skin-"] .erp8-wrapper thead th.sorting:after,
  body[class*="skin-"] .erp8-wrapper thead th.sorting_asc:before,
  body[class*="skin-"] .erp8-wrapper thead th.sorting_asc:after,
  body[class*="skin-"] .erp8-wrapper thead th.sorting_desc:before,
  body[class*="skin-"] .erp8-wrapper thead th.sorting_desc:after {
    content:none!important;display:none!important;
  }
  /* On overflowed tables the menu must be positioned against the viewport,
     while staying in its original DOM parent so delegated click handlers work. */
  body[class*="skin-"] .erp8-wrapper .dropdown-menu.erp15-floating-menu {
    position:fixed!important;z-index:2050!important;
    max-height:min(65vh,460px);overflow-y:auto!important;
    background:var(--erp15-surface);color:var(--erp15-ink);
    border:1px solid var(--erp15-border);box-shadow:0 12px 28px rgba(0,0,0,.22);
  }
  body[class*="skin-"] .erp8-wrapper .erp8-toolbar {display:flex;gap:8px;margin:9px 0;flex-wrap:wrap;align-items:center;}
  body[class*="skin-"] .erp8-wrapper .erp8-switch,
  body[class*="skin-"] .erp8-wrapper .erp8-chooser > summary {
    display:inline-flex;align-items:center;cursor:pointer;font-size:12px;
    background:var(--erp15-surface);color:var(--erp15-ink);border:1px solid var(--erp15-border);
    border-radius:6px;padding:7px 11px;
  }
  body[class*="skin-"] .erp8-wrapper .erp8-chooser {position:relative;}
  body[class*="skin-"] .erp8-wrapper .erp8-chooser-panel {
    position:absolute;inset-inline-start:0;top:calc(100% + 4px);
    min-width:240px;max-height:290px;overflow:auto;z-index:100;
    border:1px solid var(--erp15-border);background:var(--erp15-surface);
    color:var(--erp15-ink);padding:8px;border-radius:6px;
    box-shadow:0 10px 24px rgba(0,0,0,.15);
  }
  body[class*="skin-"] .erp8-wrapper .erp8-chooser-panel label {display:flex;gap:8px;padding:5px 7px;}
  body[class*="skin-"] .erp8-wrapper .erp8-export-note {font-size:11px;opacity:.85;margin:9px 0 4px;}
  body[class*="skin-"] .erp8-wrapper .erp8-compact-export-warning {font-size:11px;opacity:.85;}
}

/* V15.5: DataTables 1.10 scrollX uses three cloned tables. On wide monitors
   the original theme centers the body table once compact columns fit within
   the viewport, while head/foot remain aligned to the start edge. Pin the
   body to the same start edge (RTL=right, LTR=left); never change cell widths. */
@media screen {
  html[dir="rtl"] body[class*="skin-"] .erp8-wrapper .dataTables_scrollBody > table {
    margin-right:0!important;margin-left:auto!important;
  }
  html[dir="ltr"] body[class*="skin-"] .erp8-wrapper .dataTables_scrollBody > table {
    margin-left:0!important;margin-right:auto!important;
  }
}

/* V15.7: common controls use one visual grid, even with Select2 on some themes.
   Scope to enhanced DataTables only; never change POS or invoice inputs. */
@media screen {
  .erp8-wrapper .erp157-length-toolbar {
    display:flex!important;align-items:center!important;justify-content:flex-start;
    gap:9px;flex-wrap:wrap;min-height:36px;
  }
  .erp8-wrapper .erp157-length-toolbar > label {
    display:inline-flex!important;align-items:center!important;gap:5px;
    margin:0!important;min-height:36px;line-height:34px;
  }
  .erp8-wrapper .erp157-length-toolbar .erp8-toolbar {
    display:inline-flex!important;align-items:center!important;
    margin:0!important;padding:0!important;gap:7px;
  }
  .erp8-wrapper .erp157-length-toolbar select,
  .erp8-wrapper .erp157-length-toolbar .select2-selection--single,
  .erp8-wrapper .erp8-switch,
  .erp8-wrapper .erp8-chooser > summary {
    box-sizing:border-box!important;height:36px!important;min-height:36px!important;
    line-height:34px!important;padding-top:0!important;padding-bottom:0!important;
    vertical-align:middle!important;
  }
  .erp8-wrapper .erp157-length-toolbar select {min-width:63px;padding-inline:7px!important;}
  .erp8-wrapper .erp157-length-toolbar .select2-selection__rendered {line-height:34px!important;}
  .erp8-wrapper .erp157-length-toolbar .select2-selection__arrow {height:34px!important;}
  /* The business-defined initial ordering is preserved; heading clicks are
     suppressed by the V15 JS. The icons must not falsely suggest click sorting. */
  .erp8-wrapper th.sorting, .erp8-wrapper th.sorting_asc,
  .erp8-wrapper th.sorting_desc, .erp8-wrapper th.sorting_disabled {
    background-image:none!important;cursor:default!important;
  }
  .erp8-wrapper th.sorting::before, .erp8-wrapper th.sorting::after,
  .erp8-wrapper th.sorting_asc::before, .erp8-wrapper th.sorting_asc::after,
  .erp8-wrapper th.sorting_desc::before, .erp8-wrapper th.sorting_desc::after,
  .erp8-wrapper th.sorting_disabled::before, .erp8-wrapper th.sorting_disabled::after {
    content:none!important;display:none!important;opacity:0!important;
    background:none!important;
  }
  .erp8-wrapper thead .fa-sort, .erp8-wrapper thead .fa-sort-up,
  .erp8-wrapper thead .fa-sort-down {display:none!important;}
  /* Summary rows in operational LISTS are visually absent. The original
     tfoot and callback target nodes remain in the DOM for legacy JS. */
  .erp8-wrapper.erp8-list-summary-hidden table.erp8-table > tfoot,
  .erp8-wrapper.erp8-list-summary-hidden .dataTables_scrollFoot {display:none!important;}
  /* Reports preserve their own totals and do not inherit list hiding. */
  .erp8-wrapper.erp8-report-grid tfoot {display:table-footer-group;}
  /* Pin only a *verified last action column*, without reordering its index.
     RTL last action sits on the LEFT edge; LTR last action on the RIGHT. */
  html[dir="rtl"] .erp8-wrapper.erp8-pinned-action table.erp8-table > tbody > tr > td:last-child,
  html[dir="rtl"] .erp8-wrapper.erp8-pinned-action table.erp8-table > thead > tr > th:last-child,
  [dir="rtl"] .erp8-wrapper.erp8-pinned-action table.erp8-table > tbody > tr > td:last-child,
  [dir="rtl"] .erp8-wrapper.erp8-pinned-action table.erp8-table > thead > tr > th:last-child {
    position:sticky!important;left:0!important;z-index:3;
    background:var(--erp15-surface,#fff);
    box-shadow:2px 0 7px rgba(15,23,42,.12);
  }
  html[dir="ltr"] .erp8-wrapper.erp8-pinned-action table.erp8-table > tbody > tr > td:last-child,
  html[dir="ltr"] .erp8-wrapper.erp8-pinned-action table.erp8-table > thead > tr > th:last-child,
  [dir="ltr"] .erp8-wrapper.erp8-pinned-action table.erp8-table > tbody > tr > td:last-child,
  [dir="ltr"] .erp8-wrapper.erp8-pinned-action table.erp8-table > thead > tr > th:last-child {
    position:sticky!important;right:0!important;z-index:3;
    background:var(--erp15-surface,#fff);
    box-shadow:-2px 0 7px rgba(15,23,42,.12);
  }
  .erp8-wrapper.erp8-pinned-action table.erp8-table > thead > tr > th:last-child {z-index:4;}
  /* Equal ROW alignment, without late width manipulation on DataTables clones. */
  .erp8-wrapper table.erp8-table > thead > tr > th,
  .erp8-wrapper table.erp8-table > tbody > tr > td {
    box-sizing:border-box;vertical-align:middle!important;
  }
}
/* V16.2: no synthetic action title overlays in scrollX. DataTables owns
   header/body/footer widths; sticky is for real single-table headers only. */

/* V16 consolidated styling: restrained improvements for every enhanced DataTable.
   All selectors are under the enhanced wrapper. Do not apply fixed width,
   new padding or layout to table cells AFTER DataTables initialized: that
   can desynchronise DataTables scrollX header/body/footer clones. */
@media screen {
  body[class*="skin-"] .erp16-ui {
    --erp16-divider:var(--erp15-border,#dfe5ed);
    --erp16-hover:rgba(114,130,155,.075);
    --erp16-focus:var(--erp15-accent,#2563eb);
  }
  body[class*="skin-"] .erp16-ui .dataTables_filter input,
  body[class*="skin-"] .erp16-ui .dataTables_length select,
  body[class*="skin-"] .erp16-ui .dt-button,
  body[class*="skin-"] .erp16-ui .buttons-collection,
  body[class*="skin-"] .erp16-ui .erp8-switch,
  body[class*="skin-"] .erp16-ui .erp15-arrow {
    box-sizing:border-box;min-height:36px;vertical-align:middle;
  }
  body[class*="skin-"] .erp16-ui .dataTables_filter input {
    border-radius:7px;border:1px solid var(--erp16-divider);max-width:min(260px,52vw);
  }
  body[class*="skin-"] .erp16-ui .dataTables_filter,
  body[class*="skin-"] .erp16-ui .dataTables_length {
    min-height:36px;
  }
  body[class*="skin-"] .erp16-ui .dataTables_info,
  body[class*="skin-"] .erp16-ui .dataTables_paginate {
    line-height:1.8;
  }
  body[class*="skin-"] .erp16-ui table.erp8-table > tbody > tr:hover:not(.selected):not(.active) {
    background-color:var(--erp16-hover);
  }
  body[class*="skin-"] .erp16-ui table.erp8-table > tbody > tr > td,
  body[class*="skin-"] .erp16-ui table.erp8-table > thead > tr > th {
    vertical-align:middle;
  }
  body[class*="skin-"] .erp16-ui table.erp8-table > tbody .dropdown-toggle,
  body[class*="skin-"] .erp16-ui table.erp8-table > tbody .btn {
    border-radius:6px;
  }
  body[class*="skin-"] .erp16-ui button:focus-visible,
  body[class*="skin-"] .erp16-ui a:focus-visible,
  body[class*="skin-"] .erp16-ui input:focus-visible,
  body[class*="skin-"] .erp16-ui select:focus-visible,
  body[class*="skin-"] .erp16-ui summary:focus-visible {
    outline:2px solid var(--erp16-focus);outline-offset:2px;
  }
  body[class*="skin-"] .erp16-ui .erp15-scroll-guide {
    border-bottom:1px solid var(--erp16-divider);padding-bottom:6px;
  }
}
@media screen and (max-width:640px) {
  body[class*="skin-"] .erp16-ui .dataTables_filter,
  body[class*="skin-"] .erp16-ui .dataTables_length,
  body[class*="skin-"] .erp16-ui .dt-buttons {max-width:100%;}
  body[class*="skin-"] .erp16-ui .erp15-scroll-guide {gap:6px;}
  body[class*="skin-"] .erp16-ui .erp15-scroll-hint {flex:1;min-width:125px;}
}
@media (prefers-reduced-motion:reduce) {
  body[class*="skin-"] .erp16-ui *,
  body[class*="skin-"] .erp16-ui *::before,
  body[class*="skin-"] .erp16-ui *::after {scroll-behavior:auto!important;}
}

/* V16.1: targeted layout repairs. Keep selectors inside enhanced list wrappers;
   do not modify POS, modals, printouts or cloned scrollX column widths. */
@media screen {
  body[class*="skin-"] .erp8-wrapper .erp157-length-toolbar {
    float:none!important;width:max-content!important;max-width:100%!important;
    display:inline-flex!important;flex-wrap:nowrap!important;align-items:center!important;
    gap:8px!important;margin:0 0 5px!important;padding:0!important;
  }
  body[class*="skin-"] .erp8-wrapper .erp157-length-toolbar > label,
  body[class*="skin-"] .erp8-wrapper .erp157-length-toolbar .erp8-switch {
    width:122px!important;min-width:122px!important;max-width:122px!important;
    height:36px!important;min-height:36px!important;flex-shrink:0;
    box-sizing:border-box!important;display:inline-flex!important;align-items:center!important;
    justify-content:center!important;text-align:center!important;white-space:nowrap!important;
  }
  body[class*="skin-"] .erp8-wrapper .erp157-length-toolbar > label {gap:5px!important;margin:0!important;}
  body[class*="skin-"] .erp8-wrapper .erp157-length-toolbar .erp8-toolbar {
    margin:0!important;display:inline-flex!important;gap:6px!important;align-items:center!important;
  }
  body[class*="skin-"] .erp8-wrapper .erp15-scroll-guide {margin:3px 0 4px!important;padding:0!important;}
  body[class*="skin-"] .erp8-wrapper .dataTables_filter,
  body[class*="skin-"] .erp8-wrapper .dataTables_length {margin-bottom:5px!important;}
  body[class*="skin-"] .erp8-wrapper thead th.erp8-col-action,
  body[class*="skin-"] .erp8-wrapper tbody td.erp8-col-action,
  body[class*="skin-"] .erp8-wrapper .erp157-action-head {
    text-align:center!important;vertical-align:middle!important;
  }
  body[class*="skin-"] .erp8-wrapper tbody td.erp8-col-action > .btn-group,
  body[class*="skin-"] .erp8-wrapper tbody td.erp8-col-action > .dropdown {
    display:inline-flex;align-items:center;justify-content:center;
  }
  /* Human-sized identifiers: SKU/reference and dates must not stack letters. */
  body[class*="skin-"] .erp8-wrapper .erp15-horizontal.erp17-sized-grid thead th.erp8-col-identifier,
  body[class*="skin-"] .erp8-wrapper .erp15-horizontal.erp17-sized-grid tbody td.erp8-col-identifier {
    white-space:nowrap!important;overflow-wrap:normal!important;word-break:normal!important;
  }
  body[class*="skin-"] .erp8-wrapper .erp17-open-action-cell {
    position:relative;z-index:90!important;
  }
  body[class*="skin-"] .erp8-wrapper.erp8-pinned-action .erp17-open-action-cell {z-index:90!important;}
  body[class*="skin-"] .erp8-wrapper .erp17-open-action-row {position:relative;z-index:89;}
  body[class*="skin-"] .erp8-wrapper .dropdown-menu.erp15-floating-menu {z-index:5000!important;}
}
@media screen and (max-width:540px) {
  body[class*="skin-"] .erp8-wrapper .erp157-length-toolbar {gap:6px!important;}
  body[class*="skin-"] .erp8-wrapper .erp157-length-toolbar > label,
  body[class*="skin-"] .erp8-wrapper .erp157-length-toolbar .erp8-switch {
    width:106px!important;min-width:106px!important;max-width:106px!important;
  }
}

@media screen {
  html[dir="rtl"] body[class*="skin-"] .erp8-wrapper .erp15-viewport > table.erp17-sized-grid {
    margin-right:0!important;margin-left:auto!important;
  }
  html[dir="ltr"] body[class*="skin-"] .erp8-wrapper .erp15-viewport > table.erp17-sized-grid {
    margin-left:0!important;margin-right:auto!important;
  }
  body[class*="skin-"] .erp8-wrapper tbody td.erp8-col-date {
    unicode-bidi:plaintext;direction:ltr;text-align:center;
  }
}

/* Prevent the compact export explanation from creating an extra toolbar row. */
@media screen { body[class*="skin-"] .erp8-wrapper .erp8-compact-export-warning {display:none!important;} }

/* V16.3: purchase-like, FULL-WIDTH responsive layout for the two reviewed
 * listing screens ONLY. The DataTables JS and other ERP tables remain as-is.
 * In compact mode, share the available width instead of extending the entire
 * page; with "all columns" allow native horizontal scrolling inside the grid.
 * Do not affect scrollX clones / financial report tables / print / POS. */
@media screen {
  body[class*="skin-"] .erp-list-compact-host {
    width:100%;max-width:100%;min-width:0;
    overflow-x:auto;overflow-y:visible;
    overscroll-behavior-x:contain;
  }
  body[class*="skin-"] .erp-list-compact-host .dataTables_wrapper {
    width:100%;max-width:100%;min-width:0;
  }
  body[class*="skin-"] .erp-list-compact-host #sell_table,
  body[class*="skin-"] .erp-list-compact-host #contact_table {width:100%;}
  body[class*="skin-"] .erp-list-compact-host .erp-contact-statement-net {
    display:block;margin-top:4px;font-size:11px;line-height:1.45;
    white-space:normal;color:var(--novel-muted,#64748b);
  }
  body[class*="skin-"] .erp-list-compact-host .erp-contact-statement-net::before {
    content:attr(data-net-label);
  }
}
@media screen and (min-width:1200px) {
  body[class*="skin-"] .erp-list-compact-host .erp8-wrapper:not(:has(.dataTables_scrollHead)) #sell_table[data-erp-compact="1"],
  body[class*="skin-"] .erp-list-compact-host .erp8-wrapper:not(:has(.dataTables_scrollHead)) #contact_table[data-erp-compact="1"] {
    table-layout:fixed!important;width:100%!important;
  }
  body[class*="skin-"] .erp-list-compact-host #sell_table[data-erp-compact="1"] > thead > tr > th,
  body[class*="skin-"] .erp-list-compact-host #sell_table[data-erp-compact="1"] > tbody > tr > td,
  body[class*="skin-"] .erp-list-compact-host #contact_table[data-erp-compact="1"] > thead > tr > th,
  body[class*="skin-"] .erp-list-compact-host #contact_table[data-erp-compact="1"] > tbody > tr > td {
    box-sizing:border-box!important;min-width:0!important;
    max-width:none!important;white-space:normal!important;
    overflow-wrap:anywhere;word-break:normal;
    padding-inline:8px!important;
  }
  body[class*="skin-"] .erp-list-compact-host #sell_table[data-erp-compact="1"] > tbody > tr > td.erp8-col-identifier,
  body[class*="skin-"] .erp-list-compact-host #contact_table[data-erp-compact="1"] > tbody > tr > td.erp8-col-identifier {
    overflow-wrap:normal;white-space:nowrap!important;
    overflow:hidden;text-overflow:ellipsis;
  }
}

/* V16.4: the browser computes overflow-y:auto when overflow-x:auto and
 * overflow-y:visible are combined.  That clipped the column chooser on the
 * short five-row lists.  While the chooser is open, temporarily clip only the
 * wide table horizontally and let the chooser extend vertically.  When it
 * closes, restore the table's own horizontal scroll.  Scoped to these two
 * listing hosts; all accounting/print/POS screens are unaffected. */
@media screen {
  body[class*="skin-"] .erp-list-compact-host:has(.erp8-chooser[open]) {
    overflow-x:clip!important;
    overflow-y:visible!important;
  }
}
