/* =============================================================================
   NoExcel — overrides on top of KeenThemes Craft (light theme only).

   Stock Keen Craft wearing the NoExcel blue, plus the looks the project owner kept:
   heading polish, tabs and pills, the sidebar, DataTables sort carets, cards, table
   headers and numerals, form labels and the keyboard focus ring. Build everything else
   with Bootstrap/Keen utility classes in the template. Before adding a rule here, try
   a utility — and if you still need CSS, write down why a utility could not do it.
   ============================================================================= */

/* The NoExcel blue. Keen hard-codes its own #00A3FF family into dozens of variables
   instead of reading --bs-primary, so every one that reaches the UI is set here. The
   marketing pages pin data-bs-theme="light" on a wrapper, where Keen re-declares the
   variables, hence the second selector.
   Not overridden: success / warning / danger / info / greys / secondary stay Keen's. */
:root,
[data-bs-theme="light"] {
  --brand-primary-rgb: 53, 104, 221;
  --bs-primary: #3568dd;
  --bs-primary-rgb: var(--brand-primary-rgb);
  --bs-primary-hover: #4b79e3;
  --bs-primary-active: #2d59bf;
  --bs-primary-light: #e1e9fb;
  /* Bootstrap's own tints/shade of the primary, worked out for the brand
       (80% / 60% white, 60% black). Read by .alert-primary and *-primary-subtle. */
  --bs-primary-bg-subtle: #d7e1f8;
  --bs-primary-border-subtle: #aec3f1;
  --bs-primary-text-emphasis: #152a58;
  --bs-text-primary: #3568dd;
  --bs-link-color: #3568dd;
  --bs-link-color-rgb: var(--brand-primary-rgb);
  --bs-link-hover-color: #2d59bf;
  --bs-link-hover-color-rgb: 45, 89, 191;
  --bs-focus-ring-color: rgba(var(--brand-primary-rgb), 0.25);
  --bs-component-active-bg: #3568dd;
  --bs-component-hover-color: #3568dd;
  --bs-menu-link-color-hover: #3568dd;
  --bs-menu-link-color-show: #3568dd;
  --bs-menu-link-color-here: #3568dd;
  --bs-menu-link-color-active: #2d59bf;
  --bs-scrolltop-bg-color-hover: #2d59bf;
  --bs-ribbon-label-bg: #3568dd;
  --bs-ribbon-label-border-color: #2d59bf;
}

/* Surfaces and motion for the sidebar, cards and tables below. Borders-first theme:
   a card lifts with a 1px ring and two whisper-quiet depths, not a drop shadow. */
:root {
  --nx-border-hairline: rgba(0, 0, 0, 0.06);
  --nx-shadow-card:
    0 0 0 1px var(--nx-border-hairline), 0 1px 2px -1px rgba(0, 0, 0, 0.06),
    0 2px 6px rgba(0, 0, 0, 0.03);
  --nx-shadow-card-hover:
    0 0 0 1px rgba(var(--brand-primary-rgb), 0.25),
    0 4px 10px -2px rgba(0, 0, 0, 0.08), 0 10px 24px rgba(0, 0, 0, 0.05);
  --nx-radius-lg: 0.9rem;
  --nx-ease: cubic-bezier(0.23, 1, 0.32, 1);
  --nx-duration-fast: 120ms;
}

/* The rest of Keen's blue, which no :root variable reaches: rules that write #00a3ff,
   rgba(0,163,255,.25) or rgb(51,181,255) as a literal, and variables Bootstrap declares on the
   component itself. */

/* Checked checkbox / radio / switch and an indeterminate box. The coloured variants
   (.form-check-success …) out-rank this and keep their own colour. */
.form-check-input:checked,
.form-check-input[type="checkbox"]:indeterminate {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.form-check.form-check-solid .form-check-input[type="checkbox"]:indeterminate {
  background-color: var(--bs-primary);
}

/* Keyboard focus ring on tab / pill links. */
.nav-link:focus-visible {
  box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
}

/* Bootstrap declares these on the component itself, so :root cannot reach them: the active
   pill's fill, and the fill of a .progress-bar that carries no bg-* class. */
.nav-pills {
  --bs-nav-pills-link-active-bg: var(--bs-primary);
}

.progress,
.progress-stacked {
  --bs-progress-bar-bg: var(--bs-primary);
}

/* The chevron of an expanded accordion (a data-URI SVG, so only a full redeclaration works). */
.accordion {
  --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%233568DD'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

/* Bootstrap's hover tint for .link-primary (login page links). !important: Bootstrap's is. */
.link-primary:hover,
.link-primary:focus {
  color: var(--bs-primary-hover) !important;
}

/* -----------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings tighten as they grow — default tracking on a 28px heading reads like a document, not
   an interface — and wrap evenly instead of leaving a one-word last line. */
h1,
h2,
h3,
.h1,
.h2,
.h3 {
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p,
.text-muted,
.form-text {
  text-wrap: pretty;
}

/* Nastaliq is a connected script — the negative tracking above would break the joins. */
html[dir="rtl"] :is(h1, h2, h3, .h1, .h2, .h3) {
  letter-spacing: normal;
}

/* Urdu (RTL). A font family and an @font-face cannot be a utility class; and
   Nastaliq's tall ascenders/descenders clip at Keen's default line-heights. */
@font-face {
  font-family: "Noto Nastaliq Urdu";
  src: url("/preCompiledAssets/fonts/Noto_Nastaliq_Urdu/static/NotoNastaliqUrdu-Regular.ttf")
    format("truetype");
  font-display: swap;
}

html[dir="rtl"] body,
html[dir="rtl"] input,
html[dir="rtl"] button,
html[dir="rtl"] textarea,
html[dir="rtl"] select {
  font-family: "Noto Nastaliq Urdu", "Inter", sans-serif;
}

html[dir="rtl"]
  :is(
    body,
    h1,
    h2,
    h3,
    .h1,
    .h2,
    .h3,
    .card-title,
    .form-control,
    .form-select,
    .btn,
    .menu-title,
    .badge
  ) {
  line-height: 1.8;
}

/* Directional glyphs must mirror in RTL. Neither Bootstrap Icons nor Font Awesome
   flip themselves, and a direction-conditional transform is not a utility class. */
html[dir="rtl"] .bi-chevron-right,
html[dir="rtl"] .bi-chevron-left,
html[dir="rtl"] .bi-arrow-right,
html[dir="rtl"] .bi-arrow-left,
html[dir="rtl"] .bi-box-arrow-up-right,
html[dir="rtl"] .fa-arrow-left,
html[dir="rtl"] .fa-arrow-right {
  display: inline-block;
  transform: scaleX(-1);
}

/* -----------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

/* Hairline dividers: the aside's edge, under the logo, under the header. */
.aside {
  border-inline-end: 1px solid var(--nx-border-hairline);
}

.aside-logo,
.header {
  border-block-end: 1px solid var(--nx-border-hairline);
}

/* The menu is a flex column under the logo, so the scroll area is sized by flex rather than
   by the viewport sum in data-kt-scroll (it survives a wrapped logo or an impersonation bar).
   Primary nav stays at the top; the last section (Users / Settings / Support) is pinned to the
   bottom with a divider above it. Flex layout and a section divider are not utilities. */
.aside-menu {
  flex-shrink: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.aside-menu .menu {
  flex-grow: 1;
  min-height: 0;
  padding-block: 0.5rem 1rem;
}

.aside-menu .menu .hover-scroll-y {
  flex-grow: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.aside-menu .menu .hover-scroll-y > .menu-section:last-child {
  margin-block-start: auto;
  padding-block-start: 0.75rem;
  border-block-start: 1px solid var(--nx-border-hairline);
}

/* Scrollbar. Only Safari (and old Chromium) render these: current Chromium and Firefox follow
   Keen's scrollbar-width / scrollbar-color, which makes them ignore the pseudo-elements. */
.aside-menu .menu .hover-scroll-y::-webkit-scrollbar {
  width: 6px;
}

.aside-menu .menu .hover-scroll-y::-webkit-scrollbar-track {
  background: transparent;
}

.aside-menu .menu .hover-scroll-y::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.aside-menu .menu .hover-scroll-y:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.16);
}

.aside-menu .menu-link {
  transition:
    background-color var(--nx-duration-fast) var(--nx-ease),
    color var(--nx-duration-fast) var(--nx-ease);
}

/* The active item earns a leading marker as well as a tint — colour alone is a weak signal,
   and it is the one thing the eye scans for on every page load. A pseudo-element is not a
   utility. */
.aside-menu .menu-item .menu-link.active {
  position: relative;
  font-weight: 600;
}

.aside-menu .menu-item .menu-link.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.25rem;
  border-radius: 0 3px 3px 0;
  background-color: var(--bs-primary);
}

html[dir="rtl"] .aside-menu .menu-item .menu-link.active::before {
  border-radius: 3px 0 0 3px;
}

.aside-menu .menu-icon {
  flex-basis: 1.75rem;
}

/* -----------------------------------------------------------------------------
   Keyboard focus
   -------------------------------------------------------------------------- */

/* One brand-blue ring for whatever a keyboard can reach, drawn only for keyboard focus
   (:focus-visible), never after a mouse click. Text inputs and selects keep Keen's own focus
   style: `.form-control:focus { outline: 0 }` is more specific than this. */
:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* Buttons and menu links need !important: Keen sets `.menu-item .menu-link { outline: 0
   !important }` on sidebar and dropdown links, and Bootstrap `.btn:focus-visible { outline: 0 }`,
   so a plain rule leaves them with no focus indicator at all. */
.btn:focus-visible,
.menu-item .menu-link:focus-visible {
  outline: 2px solid var(--bs-primary) !important;
  outline-offset: 2px;
}

/* A destructive menu item (row_action `danger`) gets a pale red wash on hover and keyboard focus,
   its red text unchanged. !important: Keen's `menu-state-bg*` hover selectors are far more specific. */
.menu-link.text-danger:hover,
.menu-link.text-danger:focus-visible {
  background-color: rgba(var(--bs-danger-rgb), 0.08) !important;
}

/* -----------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  border-radius: var(--nx-radius-lg);
  box-shadow: var(--nx-shadow-card);
}

/* Concentric radius: a header flush against a rounded card needs the card's radius. */
.card > .card-header:first-child {
  border-start-start-radius: var(--nx-radius-lg);
  border-start-end-radius: var(--nx-radius-lg);
}

/* A card that is itself a link (the settings hub): lift and ring on hover/focus. */
a > .card,
.card.hover-scale {
  transition:
    box-shadow 180ms var(--nx-ease),
    transform 180ms var(--nx-ease);
}

a:hover > .card,
a:focus-visible > .card,
.card.hover-scale:hover {
  box-shadow: var(--nx-shadow-card-hover);
  transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
  a:hover > .card,
  a:focus-visible > .card,
  .card.hover-scale:hover {
    transform: none;
  }
}

/* -----------------------------------------------------------------------------
   Tables and numerals
   -------------------------------------------------------------------------- */

/* The header row demotes to a label so the data leads. Size, weight, colour and case come from
   utility classes on the <tr> (`text-gray-500 fw-bold fs-7 text-uppercase`); Craft's
   `.table:not(.table-bordered) th` forces those four to `inherit`, and the utilities win only
   because they are !important — so only tracking and wrapping live here. */
.table > thead > tr > th {
  letter-spacing: 0.04em;
  white-space: nowrap;
  vertical-align: middle;
}

/* Nastaliq is a connected script — letter-spacing breaks the joins. */
html[dir="rtl"] .table > thead > tr > th {
  letter-spacing: normal;
}

/* Row height is the biggest readability lever on a dense listing; table-sm alone packs rows too tight. */
.table > tbody > tr > td {
  padding-block: 0.7rem;
  vertical-align: middle;
}

.table-hover > tbody > tr {
  transition: background-color var(--nx-duration-fast) var(--nx-ease);
}

/* Whole-row-clickable listings (`data-row-href`) hover in the brand's light blue instead of grey.
   Driven by an attribute, which a utility class cannot express. DataTables and Keen/Bootstrap both
   paint the hover tint as an inset box-shadow on the cells, so we set that shadow to the brand colour;
   the second selector out-ranks DataTables' `table.dataTable.table-hover ... :hover > *` grey overlay. */
.table-hover > tbody > tr[data-row-href]:hover > *,
table.dataTable.table-hover > tbody > tr[data-row-href]:hover > * {
  box-shadow: inset 0 0 0 9999px var(--bs-primary-light);
}

/* Row-action dropdowns. `.menu-sub-dropdown` has no width of its own and Keen defines no `w-180px`
   (or `w-160px`) utility, so KTMenu's fixed-position dropdown would span the whole viewport.
   !important: it also fixes the menus that carry a real utility such as `w-200px`. */
.table td > .menu.menu-sub.menu-sub-dropdown {
  width: 180px !important;
}

/* Fixed-width digits for every figure compared down a column, so decimals line up. */
.table td,
.table th,
.fs-2hx,
.fs-2x,
.fs-2,
.badge {
  font-variant-numeric: tabular-nums;
}

/* DataTables sort indicators. assets/nx-datatable.js injects `.nx-sort` (an up and a down caret,
   laid out and muted with utility classes) into every sortable header. Only what a utility cannot
   express lives here: switching off Keen's own pseudo-element arrows, and turning the caret that
   matches the <th>'s `sorting_asc` / `sorting_desc` state primary. */
table.dataTable > thead > tr > th.sorting::before,
table.dataTable > thead > tr > th.sorting::after,
table.dataTable > thead > tr > th.sorting_asc::before,
table.dataTable > thead > tr > th.sorting_asc::after,
table.dataTable > thead > tr > th.sorting_desc::before,
table.dataTable > thead > tr > th.sorting_desc::after {
  display: none !important;
}

table.dataTable > thead > tr > .sorting_asc .nx-sort > .bi-caret-up-fill,
table.dataTable > thead > tr > .sorting_desc .nx-sort > .bi-caret-down-fill {
  /* !important: the carets carry `text-gray-300`, itself !important, which this must outrank. */
  color: var(--bs-primary) !important;
}

/* form_errors() renders a field's errors as a bare <ul> with no class hook, so only a descendant
   selector can reach it; in a narrow line-grid cell its 2rem indent and bullets squeeze the
   message to a word per line. */
.table td .invalid-feedback > ul {
  padding: 0;
  margin: 0;
  list-style: none;
}

/* -----------------------------------------------------------------------------
   Tabs and pills
   -------------------------------------------------------------------------- */

/* Grey until hovered, brand-dark when active; the active pill is a bold tint rather than Keen's
   solid fill. Keen's own line-tab colours are more specific and stay for inactive line tabs. */
.nav .nav-link {
  color: var(--bs-gray-700);
}

.nav .nav-link:hover,
.nav .nav-link:focus {
  color: var(--bs-primary);
}

.nav .nav-link.active,
.nav .show > .nav-link,
.nav-line-tabs .nav-item .nav-link.active,
.nav-line-tabs .nav-item .nav-link.active i {
  color: var(--bs-primary-active);
}

/* Bell menu tabs sit on the blue header: the global rules above paint the active tab brand-dark
   (blue on blue). Utilities cannot beat those selectors, so scope white text/underline here. */
#kt_menu_notifications .nav-line-tabs .nav-item .nav-link,
#kt_menu_notifications .nav-line-tabs .nav-item .nav-link i {
  color: #fff;
  opacity: 1;
}

#kt_menu_notifications .nav-line-tabs .nav-item .nav-link:not(.active) {
  opacity: 0.8;
}

#kt_menu_notifications .nav-line-tabs .nav-item .nav-link:not(.active):hover {
  opacity: 1;
}

#kt_menu_notifications .nav-line-tabs .nav-item .nav-link.active {
  border-bottom-color: #fff;
}

.nav-pills .nav-link.active {
  font-weight: bold;
  background-color: var(--bs-primary-light);
}

.nav-tabs .nav-item.show .nav-link,
.nav-tabs .nav-link.active {
  color: var(--bs-primary-active);
  font-weight: bold;
}

/* -----------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

/* Keen rounds inputs at its small radius (.425rem); the rest of the UI uses the base one. */
.form-control,
.form-select {
  border-radius: var(--bs-border-radius);
}

/* A label reads as a label, not as body copy. */
.form-label {
  font-weight: 600;
  color: var(--bs-gray-700);
  margin-bottom: 0.4rem;
}

.form-check-label {
  color: var(--bs-gray-800);
}

/* Active/inactive switch (admin/components/active_switch.html.twig): both words are in the markup
   and the one for the checkbox's current state is shown. A sibling-of-:checked selector — no
   utility class can react to the input's state, and this needs no JS. */
.nx-state-switch .form-check-input:checked ~ .form-check-label .nx-state-off,
.nx-state-switch
  .form-check-input:not(:checked)
  ~ .form-check-label
  .nx-state-on {
  display: none;
}

/* Dashboard bar charts put the full (up to 255-char) name in the tooltip title; ApexCharts' title
   is nowrap and injected by the library, so it can only be reached from here. */
.apexcharts-tooltip-title {
  max-width: 22rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* -----------------------------------------------------------------------------
   Compact layout, the admin default. Keen hard-codes every one of these gaps in px on its own
   element, per breakpoint (.content 30/20, .container(-fluid) 30/20, .toolbar 30/20, .wrapper 40,
   .card-header and .card-body 29/26), so no utility class can reach them from the shared layout:
   one rule per Keen rule, nothing else. Each selector matches the specificity of the Keen rule it
   replaces and this file loads after the Keen bundle, so it wins on order; where Keen's rule is
   more specific (`.toolbar-enabled .content .toolbar`, `.aside-default-enabled.aside-fixed
   .wrapper`) the selector repeats Keen's. Only the admin shell (admin/base.html.twig) uses these
   layout classes; the POS and the public pages have their own markup and are untouched.
   -------------------------------------------------------------------------- */

/* Header -> page title, and the gap under the title row. */
.content {
  padding-block: 1rem;
}

.toolbar-enabled .content .toolbar {
  margin-bottom: 0;
  padding-bottom: 0.5rem;
}

/* Sidebar -> card gutter; the header bar, the title row and the cards share it so they stay aligned.
   `.container` is the centred wrapper the narrow form pages use inside `.content`. */
.header .container-fluid,
.content .container,
.content .container-fluid {
  padding-inline: 1.25rem;
}

/* Far edge of the page (Keen has no right margin below lg, so only wide screens). */
@media (min-width: 992px) {
  .wrapper {
    padding-inline-end: 1.25rem;
  }
}

/* Inside the cards. Keen's `.card-px-0`/`-p-0` variants are more specific and still win. */
.card .card-header {
  padding-inline: 1.25rem;
}

.card .card-body {
  padding: 1.25rem;
}

/* The listing filter bar's `pt-6` is a utility (!important), so only !important can tighten it. */
.card-header.pt-6 {
  padding-top: 0.75rem !important;
}

/* Compact shell: the sidebar's width and the header's height. Keen writes both as bare px in a
   dozen places (aside, aside menu, wrapper padding, header height, the minimised hover state), so
   they are set once as two variables here and every rule below reads them. Desktop only for the
   width: under 992px the aside is a drawer. Not synced: Keen's `data-kt-sticky-header` rules
   (fixed header at 65px, `left: 300px`, wrapper `padding-top: 90px`) - nothing in the app puts
   `data-kt-sticky` on the header, so that state never turns on. */
:root {
  --nx-header-h: 52px;
  --nx-aside-w: 240px;
}

.header {
  height: var(--nx-header-h);
}

@media (min-width: 992px) {
  :root {
    --nx-header-h: 64px;
  }

  /* The minimised rail (100px) and its wrapper offset are Keen's own and stay: their rules are
       more specific than these, so only the expanded width changes. */
  .aside.aside-default {
    width: var(--nx-aside-w);
  }

  .aside-default-enabled.aside-fixed .wrapper {
    padding-inline-start: var(--nx-aside-w);
  }

  /* The menu is clipped by the aside, so it must be as wide as the aside's expanded (and
       hover-expanded) width. */
  .aside.aside-default .aside-menu {
    width: var(--nx-aside-w);
  }

  [data-kt-aside-minimize="on"] .aside.aside-default.aside-hoverable:hover {
    width: var(--nx-aside-w);
  }

  /* The logo block ends where the header does, so their hairlines line up. The markup's `py-5`
       is a utility (!important), so dropping the padding needs !important too. */
  .aside-logo {
    height: var(--nx-header-h);
    padding-block: 0 !important;
  }

  .aside-logo img {
    height: 40px;
  }
}

/* Login/reset split shell: brand-blue gradient + dot pattern. A gradient with a layered pattern cannot be
   expressed with utilities; reads the brand tokens so it follows the primary colour. */
.nx-auth-aside {
  background:
    radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 22px
      22px,
    linear-gradient(
      145deg,
      var(--bs-primary) 0%,
      var(--bs-primary-active) 100%
    );
}

/* Document line grid (invoice, bill, … detail screens): cells read as plain text and show a border on
   hover/focus. Keen's *-transparent classes pin the border transparent in every state (focus uses
   !important on selects), so the reveal has to out-rank them; no utility can express a state rule. */
[data-order-products] .form-control-transparent:is(:hover, :focus),
[data-order-products] .form-select-transparent:is(:hover, :focus),
[data-order-products] .select2-container--focus .select2-selection,
[data-order-products] .select2-container--open .select2-selection,
[data-order-products] .select2-selection:hover {
  border-color: var(--bs-gray-400) !important;
}

[data-order-products] .form-control-transparent.is-invalid {
  border-color: var(--bs-danger) !important;
}

/* Line grid select2s (product, bill account): select2's rendered text is nowrap, so the table's auto layout
   sized each column to the longest picked label and pushed Total behind a horizontal scroll. A 1px-wide
   container stretched back with min-width:100% contributes nothing to column sizing, so the th/td min-widths
   rule, and a long label wraps inside the column instead of widening it (the product picker wraps; see the
   next rule). !important beats select2's inline `width: 100%`; no utility can express either part. The 50px
   discount-type select2 is excluded: it keeps its fixed inline width. */
[data-line-grid]
  td
  .select2-container:not(
    select[data-discount-type-select] + .select2-container
  ) {
  width: 1px !important;
  min-width: 100%;
}

/* The product picker shows the full name: select2's single selection has a fixed height and a nowrap
   rendered line, so let it grow and wrap. Both elements are generated by select2 (no utility reach). */
[data-line-grid]
  select[data-rich-content="product"]
  + .select2-container
  .select2-selection--single {
  height: auto;
  min-height: calc(1.5em + 0.775rem + 2px);
}

[data-line-grid]
  select[data-rich-content="product"]
  + .select2-container
  .select2-selection__rendered {
  white-space: normal;
}

/* Line grid cells are top-aligned so a growing description textarea never drags the other inputs down.
   Keen pins `vertical-align: middle` on every td, which the table-level .align-top utility cannot override. */
[data-line-grid] > tbody > tr > td {
  vertical-align: top;
}

/* 50px discount-type select2 (line grid + totals footer): Keen's form-select padding (9.75px + 39px) left
   ~1px for the text, so the selected short label rendered blank. Tighten both paddings so "%", "Amt" and
   "/Unit" fit beside the arrow. select2 generates the element, so no utility class can reach it. */
select[data-discount-type-select] + .select2-container .select2-selection {
  padding-left: 0.3rem;
  padding-right: 1.3rem;
  background-position: right 0.3rem center;
  font-size: 0.85rem;
}

/* Locked approved document (form_button_divider repostNotice): a disabled <fieldset> disables native
   controls only. select2, Tagify, the date-picker's icon addon and the line-grid drag handle are
   widgets/links the browser leaves live, so they are made inert and dimmed to match. No utility can
   express a rule keyed to the fieldset's disabled state. */
fieldset[data-repost-lock]:disabled
  :is(
    .select2-container,
    .tagify,
    .input-group,
    [data-order-product-handle],
    [data-order-product-last-sale-link]
  ) {
  pointer-events: none;
}

/* Quick-add "+" buttons sit inside the locked fieldset; a disabled fieldset only greys them. Hide
   them while it is disabled (they reappear when Edit unlocks it client-side). Keyed to the fieldset's
   disabled state, which no utility can express. */
fieldset[data-repost-lock]:disabled [data-bs-target^="#quickAdd"] {
  display: none;
}

/* The open list is appended to <body> (13px) while the selected value sits inside .form-select (1.1rem),
   so the options rendered smaller than the selection. Pin the row to the form-select size in both places;
   no utility class has exactly 1.1rem. */
.nx-party-row {
  font-size: 1.1rem;
}

/* Party picker (data-rich-content="partner"): Keen makes .select2-selection a flex row, so select2's
   generated __rendered span shrinks to its content and the name/badge/balance row hugs
   the left. Let it fill the row (min-width:0 so the name still truncates). The span is created by
   select2, so no utility class can be put on it. */
select[data-rich-content="partner"]
  + .select2-container
  .select2-selection__rendered,
/* Product picker in the line grids (name / code / stock row): same flex fill, same reason. */
select[data-rich-content="product"]
  + .select2-container
  .select2-selection__rendered {
  flex: 1 1 auto;
  min-width: 0;
}

/* DataTables first paint. A listing table is server-rendered in full (every column, no length
   menu) and only reshapes once nx-datatable.js runs, so the page visibly jumped. Hide it until
   DataTables adds `.dataTable` (visibility keeps its space, so nothing below moves). Plain tables
   that are never initialised (detail-page grids, the WHT remittance picker) are excluded by id.
   The animation is a failsafe: if init never runs, the table shows after 1.5s instead of staying
   hidden. State-driven (:not(.dataTable)), which a utility class cannot express. */
.table-responsive
  > table.table-row-dashed[id$="_table"]:not(.dataTable):not(
    #bank_lines_table
  ):not(#budget_lines_table):not(#party_contacts_table):not(
    #wht_remittance_table
  ) {
  visibility: hidden;
  animation: nx-table-reveal 0s 1.5s forwards;
}

@keyframes nx-table-reveal {
  to {
    visibility: visible;
  }
}

/* DataTables first-paint loader. While the table above is hidden the card body is blank and the
   page looks frozen, so draw an animated Storyset illustration (table-loading.svg: gears bobbing,
   CSS animation embedded in the SVG, no external resources, still under prefers-reduced-motion) in the wrapper. Same exclusions as the hide rule, so
   plain tables get none. The wrapper is matched by what it contains (:has(:not(.dataTable))) and a
   pseudo-element cannot take utility classes, hence custom CSS. It disappears with the table: when
   `.dataTable` is added the :has() stops matching, and nx-spinner-hide is the same 1.5s failsafe. */
.table-responsive:has(
  > table.table-row-dashed[id$="_table"]:not(.dataTable):not(
      #bank_lines_table
    ):not(#budget_lines_table):not(#party_contacts_table):not(
      #wht_remittance_table
    )
) {
  position: relative;
  min-height: 220px;
}

.table-responsive:has(
    > table.table-row-dashed[id$="_table"]:not(.dataTable):not(
        #bank_lines_table
      ):not(#budget_lines_table):not(#party_contacts_table):not(
        #wht_remittance_table
      )
  )::after {
  content: "";
  position: absolute;
  top: 0.5rem;
  left: 50%;
  width: 200px;
  height: 200px;
  max-width: 70%;
  margin-left: -100px;
  background: url("/preCompiledAssets/storyset/svgs/table-loading.svg") center /
    contain no-repeat;
  animation: nx-spinner-hide 0s 1.5s forwards;
}

@media (max-width: 575.98px) {
  .table-responsive:has(
    > table.table-row-dashed[id$="_table"]:not(.dataTable):not(
        #bank_lines_table
      ):not(#budget_lines_table):not(#party_contacts_table):not(
        #wht_remittance_table
      )
  ) {
    min-height: 180px;
  }

  .table-responsive:has(
      > table.table-row-dashed[id$="_table"]:not(.dataTable):not(
          #bank_lines_table
        ):not(#budget_lines_table):not(#party_contacts_table):not(
          #wht_remittance_table
        )
    )::after {
    width: 160px;
    height: 160px;
    margin-left: -80px;
  }
}

@keyframes nx-spinner-hide {
  to {
    visibility: hidden;
    opacity: 0;
  }
}

/* Toasts: the toastr container is fixed to top: 12px, which sits on the header's avatar and notification
   icons; push it below the sticky header (a utility cannot target the plugin-generated container). */
#toastr-container.toastr-top-right {
  /* --nx-header-h is this file's header height (64px desktop / 52px mobile); Keen exposes none. */
  top: calc(var(--nx-header-h, 64px) + 10px);
}

/* Sticky Actions column for wide listings that scroll sideways on tablet/phone (add `nx-sticky-actions`
   to the <table>; the last column stays pinned at the inline end). Needs a solid background so the
   scrolled cells do not show through, and a hairline edge to read as a pinned column. position: sticky
   on a table cell with a border and background is not expressible with utilities. Hover tint still
   shows because Bootstrap paints it as an inset box-shadow on top of this background. */
@media (max-width: 1199.98px) {
  .nx-sticky-actions > thead > tr > th:last-child,
  .nx-sticky-actions > tbody > tr > td:last-child {
    position: sticky;
    inset-inline-end: 0;
    z-index: 1;
    background-color: var(--bs-body-bg);
    border-inline-start: 1px solid var(--nx-border-hairline);
  }
}

/* Scroll hint: a tab strip that scrolls sideways fades out at its inline end until scrolled to the
   end (class toggled by the strip scroll hint in global.js). A mask gradient tied to a JS state class
   is not expressible with utilities. */
.nx-scroll-fade-end {
  -webkit-mask-image: linear-gradient(
    to right,
    #000 calc(100% - 40px),
    transparent
  );
  mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
}

html[dir="rtl"] .nx-scroll-fade-end {
  -webkit-mask-image: linear-gradient(
    to left,
    #000 calc(100% - 40px),
    transparent
  );
  mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent);
}

/* Multi-line text clamp: Bootstrap/Keen only ship single-line text-truncate, so a 2-line
   description needs line-clamp, which no utility expresses. */
.nx-line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Line grid headers wrap: the global `thead th { white-space: nowrap }` would let a long label
   ("Price Exc. Tax", "GST Rate %") set its column's width. The grid's own table is auto-layout and
   shares spare width by content, so labels must be allowed to break. Needs a selector; no utility
   beats the nowrap rule on a per-table basis. */
[data-line-grid] > thead > tr > th {
  white-space: normal;
}

/* Line grid cells use tighter side padding than Keen's 9.75px: with thirteen columns the padding alone
   was ~250px of the row, forcing a horizontal scrollbar on a laptop. Cells are generated by several
   row partials, so one selector beats a px-* class on every td/th. */
[data-line-grid] > thead > tr > th,
[data-line-grid] > tbody > tr > td {
  padding-left: 0.3rem;
  padding-right: 0.3rem;
}
