/*
 * Fit to the screen (CLAUDE.md 68): every page of the web ERP scrolls up and down only, never sideways,
 * at any width from a phone to a wide monitor. Loaded after app.css by layouts.partials.css.
 * Lists (DataTables) show every column in one row, wrapping to fit, and become cards only when even that
 * does not fit (common.js marks .dt-tight / .dt-cards); this file styles them, keeps fields, boxes and plain
 * tables inside their column, and makes the sidebar a strip of icons that opens over the page.
 */

/* Select boxes (select2 sizes itself in pixels when drawn) and input groups never pass their column. */
.select2-container {
    max-width: 100%;
}
.input-group {
    max-width: 100%;
}
/* select2 hides the real select in a 1px box; a width class (.width-100) must not stretch it past the page. */
select.select2-hidden-accessible {
    width: 1px !important;
    max-width: 1px !important;
}
.input-group > .form-control,
.input-group > .select2-container {
    min-width: 0;
}

/* An input group holding a select2 box (a select with a + or an icon beside it) shares the row as flex. */
.input-group:has(> .select2-container) {
    display: flex;
    align-items: stretch;
    width: 100%;
}
.input-group:has(> .select2-container) > .select2-container {
    flex: 1 1 auto;
    width: auto !important;
    min-width: 0;
}
.input-group:has(> .select2-container) > .input-group-addon,
.input-group:has(> .select2-container) > .input-group-btn {
    display: flex;
    align-items: center;
    width: auto;
}
.input-group:has(> .select2-container) > .input-group-btn > .btn {
    height: 100%;
}
/* File fields and a row put straight inside another row (no column between) stay inside the page. */
#scrollable-container input[type='file'] {
    max-width: 100%;
}
#scrollable-container .row > .row,
#scrollable-container .dataTables_wrapper .row,
.dataTables_wrapper .row {
    margin-left: 0;
    margin-right: 0;
}

/* A list takes the width it is given; its scroll area (scrollY) never scrolls sideways. */
.dataTables_wrapper.dt-fit .dataTables_scrollBody {
    overflow-x: hidden !important;
}
/* The owner's exception (2026-11-07, docs/context/68): a list marked data-fit-cards="off" (all sales, customers,
   suppliers, the home page's Sales Order widget) keeps its rows on a phone, one line each, and its own box
   scrolls left and right (.dt-scroll-x, common.js); the page still does not. */
.dataTables_wrapper.dt-fit.dt-scroll-x .dataTables_scrollBody {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}
.dataTables_wrapper.dt-scroll-x table.dataTable > tbody > tr > td,
.dataTables_wrapper.dt-scroll-x table.dataTable > thead > tr > th,
.dataTables_wrapper.dt-scroll-x table.dataTable > tfoot > tr > th,
.dataTables_wrapper.dt-scroll-x table.dataTable > tfoot > tr > td {
    white-space: nowrap;
}
.dataTables_wrapper.dt-scroll-x .dataTables_scrollBody > table.dataTable {
    width: max-content !important;
    min-width: 100%;
}
/* A list's open Actions menu sits over the page (common.js): the boxes around it hold nothing that would
   keep it inside them (a card's lift on the pointer is a transform) until it closes. */
.dt-menu-host {
    transform: none !important;
    filter: none !important;
    backdrop-filter: none !important;
    perspective: none !important;
    will-change: auto !important;
    contain: none !important;
    /* at once: a lift that eased out (tw-transition-all, 200 ms) still held the menu while it was placed,
       so it opened at the screen's corner or beside its button (the owner's screenshot, 2026-11-05) */
    transition: none !important;
}
table.dataTable > thead > tr > th {
    white-space: normal;
}
/* A heading made full width by its class (the Action column of Customers and Stock transfers) takes its
   content's width; the room goes to the columns with text. */
table.dataTable > thead > tr > th.tw-w-full {
    width: auto;
}
/* Step 2 (.dt-tight): values wrap (the shortest stay whole), in a tighter cell; long words (emails) break. */
.dataTables_wrapper.dt-tight table.dataTable > thead > tr > th,
.dataTables_wrapper.dt-tight table.dataTable > tbody > tr > td,
.dataTables_wrapper.dt-tight table.dataTable > tfoot > tr > td,
.dataTables_wrapper.dt-tight table.dataTable > tfoot > tr > th {
    padding: 6px 5px;
    font-size: 0.92em;
}
.dataTables_wrapper.dt-tight table.dataTable > thead > tr > th.sorting,
.dataTables_wrapper.dt-tight table.dataTable > thead > tr > th.sorting_asc,
.dataTables_wrapper.dt-tight table.dataTable > thead > tr > th.sorting_desc {
    padding-right: 18px;
}
.dataTables_wrapper.dt-tight table.dataTable > thead > tr > th.sorting:after,
.dataTables_wrapper.dt-tight table.dataTable > thead > tr > th.sorting_asc:after,
.dataTables_wrapper.dt-tight table.dataTable > thead > tr > th.sorting_desc:after {
    right: 3px;
}
.dataTables_wrapper.dt-tight table.dataTable > tbody > tr > td.dt-nowrap:not(.dt-short) {
    white-space: normal;
}
.dataTables_wrapper.dt-tight table.dataTable > tbody > tr > td:not(.dt-nowrap) {
    overflow-wrap: anywhere;
}
table.dataTable > tbody > tr > td .btn-group {
    white-space: nowrap;
}
/* Step 3 (.dt-tighter, a computer only): a smaller type, the least padding, any long word breaks; dates,
   amounts and mobiles still stay whole. */
.dataTables_wrapper.dt-tighter table.dataTable > thead > tr > th,
.dataTables_wrapper.dt-tighter table.dataTable > tbody > tr > td,
.dataTables_wrapper.dt-tighter table.dataTable > tfoot > tr > td,
.dataTables_wrapper.dt-tighter table.dataTable > tfoot > tr > th {
    padding: 5px 3px;
    font-size: 0.85em;
}
.dataTables_wrapper.dt-tighter table.dataTable > tbody > tr > td.dt-nowrap:not(.dt-short) {
    overflow-wrap: anywhere;
}
.dataTables_wrapper.dt-tighter table.dataTable > thead > tr > th.sorting,
.dataTables_wrapper.dt-tighter table.dataTable > thead > tr > th.sorting_asc,
.dataTables_wrapper.dt-tighter table.dataTable > thead > tr > th.sorting_desc {
    padding-right: 14px;
}
/* Step 4 (.dt-squeeze, a computer only): the columns with nothing on the shown rows (.dt-void) fold to no
   width; their headings stay on the page for the export buttons. */
.dataTables_wrapper.dt-squeeze table.dataTable th.dt-void,
.dataTables_wrapper.dt-squeeze table.dataTable td.dt-void {
    width: 0 !important;
    max-width: 0;
    padding: 0 !important;
    overflow: hidden;
    font-size: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
}
.dataTables_wrapper.dt-squeeze table.dataTable th.dt-void:before,
.dataTables_wrapper.dt-squeeze table.dataTable th.dt-void:after {
    display: none;
}
/* What an empty cell holds (an empty label, a zero amount's span with its own size) folds with it, or
   the rows keep a few pixels the headings do not and every heading after it drifts. */
.dataTables_wrapper.dt-squeeze table.dataTable th.dt-void > *,
.dataTables_wrapper.dt-squeeze table.dataTable td.dt-void > * {
    display: none !important;
}
/* Step 5 (.dt-cards, a phone): each record is a card (the rules shared with plain tables below); the
   list grows with the page instead of scrolling inside its own box. The headings row is out of sight but
   still on the page: the export and print buttons take the columns whose headings are shown. */
.dataTables_wrapper.dt-cards .dataTables_scrollHead,
.dataTables_wrapper.dt-cards table.dataTable > thead,
.dataTables_wrapper.dt-cards .dataTables_scrollBody > table > tfoot {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    border: 0 !important;
}
.dataTables_wrapper.dt-cards .dataTables_scrollBody {
    height: auto !important;
    max-height: none !important;
}
.dataTables_wrapper.dt-cards table.dataTable > tbody > tr {
    background: #fff !important;
}
.dataTables_wrapper.dt-cards table.dataTable td.dt-blank {
    display: none !important;
}

/* A heading row (title and its buttons) and a row of buttons wrap when they do not fit. */
#scrollable-container .tw-flex.tw-justify-between:not(.tw-flex-nowrap),
#scrollable-container .tw-flex.tw-gap-2:not(.tw-flex-nowrap) {
    flex-wrap: wrap;
}

/* A link styled as a button ("Add new product") wraps in a narrow column instead of poking out. */
#scrollable-container .btn.btn-link {
    white-space: normal;
}

/* Justified tabs (Bootstrap lays them out as one row of table cells) wrap onto more rows when many. */
.nav-tabs.nav-justified {
    display: flex;
    flex-wrap: wrap;
}
.nav-tabs.nav-justified > li {
    display: block;
    float: none;
    flex: 1 1 auto;
    width: auto;
}

/* A label (badge) with a long text wraps instead of running past its box (Bootstrap keeps it on one line). */
#scrollable-container .label {
    white-space: normal;
}

/* Long words (codes, emails, addresses) wrap instead of pushing the page wider. */
#scrollable-container .box-body,
#scrollable-container .tw-dw-card,
#scrollable-container .modal-body {
    overflow-wrap: break-word;
}
#scrollable-container img,
#scrollable-container iframe,
#scrollable-container video {
    max-width: 100%;
}

/* Plain tables on a phone: cells wrap (Bootstrap keeps them on one line and scrolls). Rows and columns
   keep a narrower gutter, so a row inside a card's small padding no longer pokes out (and text gets room). */
@media (max-width: 767px) {
    #scrollable-container .row {
        margin-left: -8px;
        margin-right: -8px;
    }
    #scrollable-container .row > [class*='col-'] {
        padding-left: 8px;
        padding-right: 8px;
    }
    .table-responsive > .table > tbody > tr > td,
    .table-responsive > .table > tfoot > tr > td {
        white-space: normal;
    }
}

/* The list toolbar: entries, buttons and search on one row, wrapping on a narrow screen. */
.dt-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
}
.dt-toolbar .dataTables_length,
.dt-toolbar .dataTables_filter {
    float: none;
    margin: 0;
    text-align: start;
}
.dt-toolbar .dt-buttons {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    float: none;
    margin: 0;
}
.dt-toolbar .dt-buttons > .btn {
    margin: 0;
    float: none;
}
@media (max-width: 767px) {
    .dt-toolbar {
        justify-content: center;
    }
    div.dataTables_wrapper .dt-toolbar div.dataTables_filter,
    div.dataTables_wrapper .dt-toolbar div.dataTables_filter label,
    div.dataTables_wrapper .dt-toolbar div.dataTables_filter input {
        width: 100%;
        margin: 0;
    }
}
/* "Showing 1 to 10 of 50 entries" and the page buttons wrap in a narrow box. */
div.dataTables_wrapper div.dataTables_info,
div.dataTables_wrapper div.dataTables_paginate {
    white-space: normal;
}
table.dataTable > tbody > tr > td.dt-nowrap {
    white-space: nowrap;
}

/*
 * A plain table wider than its box (fit-stack.js adds .fit-stack), and a list that does not fit even in
 * tight cells (.dt-cards): one card per row, each value under its column's name. Rows hidden by the page
 * stay hidden.
 */
table.fit-stack,
table.fit-stack > tbody,
table.fit-stack > tfoot,
table.fit-stack > tbody > tr,
table.fit-stack > tfoot > tr,
.dt-cards table.dataTable,
.dt-cards table.dataTable > tbody,
.dt-cards table.dataTable > tfoot,
.dt-cards table.dataTable > tbody > tr,
.dt-cards table.dataTable > tfoot > tr {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
}
table.fit-stack,
.dt-cards table.dataTable {
    border: 0 !important;
    background: transparent;
}
table.fit-stack > thead {
    display: none;
}
table.fit-stack > tbody > tr,
table.fit-stack > tfoot > tr,
.dt-cards table.dataTable > tbody > tr,
.dt-cards table.dataTable > tfoot > tr {
    margin-bottom: 10px;
    padding: 4px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}
table.fit-stack > tbody > tr > td,
table.fit-stack > tbody > tr > th,
table.fit-stack > tfoot > tr > td,
table.fit-stack > tfoot > tr > th,
.dt-cards table.dataTable > tbody > tr > td,
.dt-cards table.dataTable > tfoot > tr > td,
.dt-cards table.dataTable > tfoot > tr > th {
    display: flow-root;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 7px 0 !important;
    border: 0 !important;
    border-bottom: 1px solid #f3f4f6 !important;
    text-align: end;
    white-space: normal !important;
    overflow-wrap: anywhere;
}
table.fit-stack > tbody > tr > td:last-child,
table.fit-stack > tfoot > tr > td:last-child,
.dt-cards table.dataTable > tbody > tr > td:last-child,
.dt-cards table.dataTable > tfoot > tr > td:last-child {
    border-bottom: 0 !important;
}
/* The column's name on the left; the value (text, labels, buttons) on the right, a full-width field below. */
table.fit-stack td[data-fit-label]::before,
table.fit-stack th[data-fit-label]::before,
.dt-cards table.dataTable td[data-fit-label]::before,
.dt-cards table.dataTable th[data-fit-label]::before {
    content: attr(data-fit-label);
    float: inline-start;
    max-width: 55%;
    margin-inline-end: 12px;
    font-weight: 600;
    color: #4b5563;
    text-align: start;
}
table.fit-stack td:empty {
    display: none;
}

/* The dashboard's table cards (Tailwind's "inline-block min-w-full" wrapper grows with its table): the
   wrapper takes the card's width, so the list inside folds to it. */
#scrollable-container .tw-overflow-x-auto > .tw-inline-block.tw-min-w-full {
    display: block;
    width: 100%;
}

/* Page by page. The ledger's heading row sat beside the floated summary boxes, squeezed to nothing. */
#scrollable-container .ledger-table-header-row {
    clear: both;
}

/*
 * The sidebar on a computer, as in the Play Console: a strip of icons that leaves the page its width. With
 * the pointer on it (or the keyboard's focus in it) it opens over the page with the names and the open
 * menu, and closes when the pointer leaves; the page does not move. Phones and tablets keep the menu that
 * slides in from the menu button, and a touch screen without a mouse keeps the full sidebar.
 */
@media (min-width: 992px) and (hover: hover) and (pointer: fine) {
    .thetop > aside.side-bar {
        --rail: 4.5rem;
        width: var(--rail);
        z-index: 1030;
        overflow-x: hidden;
        transition: width 0.16s ease, margin 0.16s ease, box-shadow 0.16s ease;
    }
    .thetop > aside.side-bar:hover,
    .thetop > aside.side-bar:has(:focus-visible) {
        width: 16rem;
        margin-inline-end: calc(var(--rail) - 16rem);
        box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
        transition-delay: 0.08s;
    }
    .thetop > aside.side-bar:not(:hover):not(:has(:focus-visible)) #side-bar {
        padding-left: 8px;
        padding-right: 8px;
    }
    .thetop > aside.side-bar:not(:hover):not(:has(:focus-visible)) #side-bar a > span,
    .thetop > aside.side-bar:not(:hover):not(:has(:focus-visible)) #side-bar a > svg.svg {
        display: none;
    }
    .thetop > aside.side-bar:not(:hover):not(:has(:focus-visible)) #side-bar .chiled {
        display: none !important;
    }
    .thetop > aside.side-bar:not(:hover):not(:has(:focus-visible)) #side-bar a {
        justify-content: center;
        gap: 0;
        padding-left: 0;
        padding-right: 0;
    }
    /* The business's name: its first letter while the strip is closed. */
    .thetop > aside.side-bar:not(:hover):not(:has(:focus-visible)) .side-bar-heading {
        font-size: 0;
        white-space: nowrap;
    }
    .thetop > aside.side-bar:not(:hover):not(:has(:focus-visible)) .side-bar-heading::first-letter {
        font-size: 1.25rem;
    }
}
