:root {
    --oxmo-primary: #1d4ed8;
    --oxmo-charcoal: #1f2937;
    --oxmo-charcoal-light: #374151;
    --oxmo-bg: #f4f5f7;
}

/*
 * overflow-x: hidden here forces the browser to auto-compute overflow-y too (CSS
 * overflow spec), turning body into its own scroll container — but without a bounded
 * height, that container never actually scrolls itself, which breaks position: sticky
 * for anything inside it (the sidebar just scrolls away with the page). Giving html/body
 * a real height makes body's scrolling genuine, so sticky positions against it correctly.
 */
html, body {
    overflow-x: hidden;
    height: 100%;
}

body {
    background: var(--oxmo-bg);
    font-size: 13px;
    line-height: 1.35;
}

.table {
    font-size: 0.85em;
}

.table td, .table th {
    padding: 0.4rem 0.6rem;
}

.form-label {
    margin-bottom: 0.2rem;
    font-size: 0.85em;
}

/*
 * Bootstrap sets its own font-size/line-height (in rem, off the page's 16px root) on most
 * components, which overrides the 13px/1.35 set on body above — that's why text fields,
 * dropdowns, menus, buttons, and help text drifted to inconsistent sizes across pages.
 * Pin them all back to the same baseline here instead of per-page overrides.
 */
.btn,
.form-control,
.form-select,
.form-check-label,
.input-group-text,
.dropdown-menu,
.dropdown-item,
.modal-body,
.modal-footer,
.card-text,
.alert,
.badge,
.form-text,
.list-group-item,
.page-link,
.nav-tabs .nav-link,
.tooltip,
.popover-body,
small,
.small {
    font-size: 13px;
    line-height: 1.35;
}

.btn-sm,
.form-control-sm,
.form-select-sm {
    font-size: 12px;
}

.mb-3 {
    margin-bottom: 0.65rem !important;
}

.modal-body hr {
    margin: 0.75rem 0;
}

/* ---------- Login page ---------- */
.login-wrapper {
    min-height: 100vh;
    background: radial-gradient(circle at top, var(--oxmo-charcoal-light) 0%, var(--oxmo-charcoal) 65%);
    display: flex;
    align-items: center;
}

.login-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.5rem;
}

.login-brand .brand-mark {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--oxmo-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
}

.login-brand .name {
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--oxmo-charcoal);
}

.login-brand .tagline {
    font-size: 0.7rem;
    color: #8a8a8a;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Phone: a taller search box that is easy to hit with a thumb (user 2026-10-13). */
@media (max-width: 767.98px) {
    .m-big-search .form-control, .m-big-search .input-group-text { height: 3.1rem; font-size: 1rem; }
    .m-big-search .input-group-text { padding: 0 0.9rem; font-size: 1.1rem; }
}

/* Phone: the order details screen is split into bordered sections. */
@media (max-width: 767.98px) {
    #detailBody .d-sec { border: 1px solid #e5e7eb; border-radius: 0.65rem; padding: 0.7rem 0.8rem; margin-bottom: 0.75rem; background: #fff; }
    #detailBody .d-sec .m-section-title { margin-bottom: 0.5rem; }
    #detailBody .d-sec .btn { margin-bottom: 0.4rem; }
    /* ACTIONS: every button on its own full-width line. */
    #detailBody .d-actions { display: flex; flex-direction: column; }
    #detailBody .d-actions > .btn { width: 100%; margin: 0 0 0.5rem 0 !important; padding: 0.6rem 0.75rem; font-size: 0.95rem; }
}

/* Phone: pages whose filter bar keeps only the search box (.m-hide parts are hidden, .m-search fills the width). */
@media (max-width: 767.98px) {
    .m-hide { display: none !important; }
    .m-search { max-width: none !important; width: 100%; margin-left: 0 !important; }
}

/* Phone: Ledger Details party list - each party is a row with its name on top and OXMO / OXFORD / CASH / TOTAL under it
   (a four-column grid, so nothing scrolls sideways). The Station / SM columns are hidden. */
@media (max-width: 767.98px) {
    #ledgerTable.p-list, #ledgerTable.p-list tbody { display: block; width: 100%; }
    #ledgerTable.p-list thead { display: none; }
    #ledgerTable.p-list tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.15rem 0.3rem; padding: 0.55rem 0.6rem; border-bottom: 1px solid #eef0f2; }
    #ledgerTable.p-list td { display: block; padding: 0; border: 0; font-size: 0.72rem; text-align: left !important; white-space: nowrap; background: transparent; }
    #ledgerTable.p-list td.ld-hide, #ledgerTable.p-list .ld-code { display: none; }
    #ledgerTable.p-list td:first-child { grid-column: 1 / -1; font-size: 0.85rem; font-weight: 600; white-space: normal; margin-bottom: 0.1rem; }
    #ledgerTable.p-list td[data-l]::before { content: attr(data-l); display: block; font-size: 0.58rem; letter-spacing: 0.4px; color: #8a8a8a; font-weight: 600; }
}
/* Phone: an open account ledger shows the Date / Type / Amount list (#ledgerMobile); the party list keeps the grid above. */
#ledgerMobile, #partyCard { display: none; }
.dash-main:not(.is-accounts) #aStatCards { display: none !important; }
.dash-main:not(.is-sales) #mStatCards, .dash-main:not(.is-sales) #revenueHeading { display: none !important; }   /* the phone summary cards (ACTIONS / ORDERS / REVENUE) belong to the sales login only */
@media (max-width: 767.98px) {
    .app-main.ledger-detail #ledgerCard { display: none; }
    .app-main.ledger-detail #ledgerMobile { display: block; }
    .app-main.ledger-detail #partyCard { display: block; }
    .app-main.ledger-detail #summary { display: none; }   /* the party card replaces the one-line summary */
    #partyCard .pc-name { font-size: 1.05rem; font-weight: 700; line-height: 1.25; }
    #partyCard .pc-code { font-size: 0.8rem; color: #6b7280; margin-bottom: 0.6rem; }
    #partyCard .pc-lines { font-size: 0.9rem; }
    #ledgerMobile .lm-row:active { background: #f1f3f5; }
    #ledgerMobileTable th, #ledgerMobileTable td { padding: 0.55rem 0.5rem; font-size: 0.8rem; }
}

.m-centres { display: none; }

/* Phone: Stock Register keeps the item name, the suggested Cash / Bill prices (roles that see prices) and the total stock. */
@media (max-width: 767.98px) {
    #stockTable th:not(:first-child):not(:last-child), #stockTable td:not(:first-child):not(:last-child) { display: none; }
    #stockTable.has-prices th:nth-child(4), #stockTable.has-prices th:nth-child(5), #stockTable.has-prices td:nth-child(4), #stockTable.has-prices td:nth-child(5) { display: table-cell; text-align: right; white-space: nowrap; }
    #stockTable.has-prices td:nth-child(4), #stockTable.has-prices td:nth-child(5) { font-size: 0.85rem; }
    #stockTable td:first-child { white-space: normal !important; }
    #stockTable td:first-child .small { display: none; }   /* no SKU under the item name on the phone */
    #stockTable .m-centres { display: flex; flex-wrap: wrap; gap: 0.2rem 0.35rem; margin-top: 0.25rem; }
    #stockTable .mc-chip { font-size: 0.66rem; color: #4b5563; background: #f1f3f5; border-radius: 0.4rem; padding: 0.05rem 0.4rem; white-space: nowrap; }
    #stockTable .mc-chip.neg { color: #b42318; background: #fdeceb; }
    #stockTable td:last-child, #stockTable th:last-child { text-align: right; white-space: nowrap; }
}

/* Phone: Sales Orders list as one card per order (the card list is d-md-none, the table d-none d-md-block). */
@media (max-width: 767.98px) {
    .order-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 0.7rem; padding: 0.8rem 0.9rem; margin-bottom: 0.65rem; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
    .order-card:active { background: #f8f9fa; }
    .order-card[data-open] { cursor: pointer; }
    .order-card .oc-no { font-weight: 700; font-size: 0.95rem; }
    .order-card .oc-party { font-weight: 600; margin: 0.25rem 0 0.35rem; line-height: 1.25; }
    .order-card .oc-meta { display: flex; flex-wrap: wrap; gap: 0.2rem 0.85rem; font-size: 0.78rem; color: #6b7280; margin-bottom: 0.15rem; }
    .order-card .oc-by { font-size: 0.75rem; color: #8a8a8a; }
    .order-card .oc-amt { font-size: 1.15rem; font-weight: 800; }
    .order-card .oc-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.65rem; padding-top: 0.6rem; border-top: 1px solid #eef0f2; }
    .order-card .oc-actions .btn { margin: 0 !important; }
}

/* Phone: less space at the top of the dashboard (user 2026-10-13). */
@media (max-width: 767.98px) {
    .dash-main #topbar { margin-bottom: .35rem; padding-top: .3rem; padding-bottom: .3rem; }
    .dash-main .page-header { margin-bottom: .3rem; }
    .dash-main .page-header h4 { font-size: 1.05rem; line-height: 1.2; }
    .dash-main #scopeLine { line-height: 1.15; }
    /* Sales login: nothing between the header and the four cards - no title, no "My orders" counters. */
    .dash-main.is-sales .page-header, .dash-main.is-sales #salesStagesBox { display: none !important; }
    .dash-main.is-sales #topbar { margin-bottom: .6rem; }
    /* accounts: no tables or charts on the phone except the Revenue bar chart (the cards open the orders / receipts pages) */
    /* accounts: nothing between the (sticky) header and the status cards - no title, salesperson filter or "Pending actions" line */
    .dash-main.is-accounts .page-header, .dash-main.is-accounts #pendingBox > .d-flex:first-child, .dash-main.is-accounts #welcome { display: none !important; }
    .dash-main.is-accounts #topbar { margin-bottom: .6rem; position: sticky; top: 0; z-index: 1030; }   /* the header stays on screen while scrolling */
    .dash-main.is-accounts #pendingGroups, .dash-main.is-accounts #pendingTiles { display: none; }
    .dash-main.is-accounts #dashBody > :not(#periodCard):not(#revenueCard):not(#mStatCards):not(#revenueHeading) { display: none !important; }
    .dash-main.is-accounts #pendingBox > .d-flex:first-child { margin-bottom: 0.5rem; }   /* accounts: the three status cards replace the nine tiles on the phone */
    .dash-main.is-sales #periodCard, .dash-main.is-accounts #periodCard { display: none; }   /* no period / month filters on the phone */
    /* Phone, sales login: the dashboard ends with the Revenue chart (no item-group charts, no pending / balance lists). */
    .dash-main.is-sales #dashBody > :not(#mStatCards):not(#revenueCard):not(#revenueHeading) { display: none !important; }
    .dash-main.is-sales #revenueCard .card-header { display: none; }   /* the REVENUE heading above replaces it */
}

/* Phone: the sales dashboard's four summary cards - two per row, softly coloured (d-md-none: desktop never shows them). */
@media (max-width: 767.98px) {
    .m-section-title { display: flex; align-items: center; gap: 0.6rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.6px; color: #6b7280; margin: 0 0 0.85rem 0.15rem; }
    .m-section-title::after { content: ''; flex: 1; height: 1px; background: #d1d5db; }
    .m-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; margin-bottom: 0.65rem; }
    .m-action-btn { display: flex; align-items: center; justify-content: center; min-height: 2.9rem; padding: 0.5rem 0.4rem; border-radius: 0.7rem; background: var(--oxmo-primary, #1d4ed8); color: #fff; font-weight: 600; font-size: 0.85rem; text-decoration: none; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); white-space: nowrap; }
    .m-action-btn:active { filter: brightness(0.92); }
    .m-action-green { background: #198754; }
    .m-stat-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
    .m-stat-card { --m-accent: #6b7280; --m-tint: #f3f4f6; --m-edge: #e5e7eb; display: flex; flex-direction: column; justify-content: space-between; min-height: 6.4rem; padding: 0.85rem 0.9rem; background: #fff; border: 1px solid #e5e7eb; border-top: 3px solid var(--m-accent); border-radius: 0.7rem; color: inherit; text-decoration: none; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
    .m-stat-card:active { filter: brightness(0.97); }
    .m-stat-label { font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.4px; display: flex; flex-direction: column; color: #374151; line-height: 1.25; }
    .m-stat-label small { font-weight: 400; font-size: 0.68rem; color: #8a8a8a; text-transform: none; letter-spacing: 0; margin-top: 0.1rem; }
    .m-stat-num { font-size: 2.1rem; font-weight: 800; line-height: 1; margin-top: 0.5rem; color: var(--m-accent); }
    /* Pantone: Delicate Blue 12-4202, Veiled Vista 12-6000, 9121 C yellow #F1F0B0, Pink Marshmallow 12-2907 */
    .m-stat-card.m-active { box-shadow: 0 0 0 2px var(--m-accent); }
    .m-blue  { --m-accent: #4f86a8; --m-tint: #c2dae7; --m-edge: #a9c8da; }
    .m-green { --m-accent: #4b9561; --m-tint: #c8e5cc; --m-edge: #addbb3; }
    .m-amber { --m-accent: #a39a1a; --m-tint: #f1f0b0; --m-edge: #e3e194; }
    .m-rose  { --m-accent: #c4628a; --m-tint: #f6e0e9; --m-edge: #ecc6d6; }
}
/* Phone: a narrower, taller login card with larger fields (user 2026-10-13). */
@media (max-width: 767.98px) {
    .login-wrapper .col-md-4 { flex: 0 0 auto; width: 80%; max-width: 330px; }
    .login-card .card-body { padding: 2.75rem 1.5rem 2.5rem !important; }
    .login-brand { margin-bottom: 2.25rem; }
    .login-brand .brand-mark { width: 76px; height: 76px; font-size: 1.6rem; margin-bottom: 1rem; }
    .login-brand .name { font-size: 1.45rem; }
    .login-card .form-label { font-size: 0.95rem; margin-bottom: 0.4rem; }
    .login-card .mb-3 { margin-bottom: 1.5rem !important; }
    .login-card .form-control { height: 3.25rem; font-size: 1.05rem; padding: 0.5rem 0.9rem; }
    .login-card .btn { height: 3.25rem; font-size: 1.05rem; margin-top: 0.5rem; }
}
/* ---------- App shell ---------- */
#sidebar {
    width: 210px;
    background: var(--oxmo-charcoal);
    color: #e5e7eb;
    flex-shrink: 0;
    overflow-x: hidden;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

#sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#sidebar .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 0.55rem;
    background: var(--oxmo-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.75rem;
    flex-shrink: 0;
}

#sidebar .brand .name {
    font-weight: 700;
    font-size: 0.85rem;
}

#sidebar .nav-group-label {
    padding: 0.5rem 0.85rem 0.15rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

#sidebar .nav-link {
    color: #cbd5e1;
    padding: 0.35rem 0.85rem;
    border-radius: 0;
    font-size: 0.8rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar .nav-link .bi {
    font-size: 0.85em;
}

#sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

#sidebar .nav-link.active {
    background: var(--oxmo-primary);
    color: #fff;
}

.app-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

#topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    padding: 0.45rem 1.25rem;
    margin: -1.25rem -1.25rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    font-size: 0.8rem;
    color: #374151;
}

.app-main {
    flex: 1;
    padding: 1.25rem;
    min-width: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.page-header h4 {
    font-size: 1.1rem;
}

/* Type-to-search item box (enhanceSearchSelect in app.js) */
.ss-list {
    position: fixed;
    z-index: 2000;
    max-height: 280px;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .375rem;
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .18);
    font-size: .875rem;
}
.ss-opt { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem .65rem; cursor: pointer; }
.ss-opt.active, .ss-opt:hover { background: var(--bs-primary-bg-subtle); }
.ss-sku { color: var(--bs-secondary-color); font-size: .75rem; white-space: nowrap; align-self: center; }
.ss-empty, .ss-more { padding: .4rem .65rem; color: var(--bs-secondary-color); font-size: .8rem; }

/* ---------- Mobile: drawer menu, bottom nav, order cards ---------- */
.drawer-btn { display: none; border: 0; background: transparent; font-size: 1.5rem; line-height: 1; padding: 0 .5rem 0 0; color: #374151; }
.drawer-backdrop { display: none; }
#bottomNav { display: none; }
.order-card { border: 1px solid #e5e7eb; border-radius: .75rem; background: #fff; padding: .85rem 1rem; display: block; color: inherit; text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.order-card:active { background: #f3f4f6; }
.order-card .oc-party { font-weight: 600; font-size: 1rem; line-height: 1.25; }
.order-card .oc-meta { color: #6b7280; font-size: .8rem; }
.stage-chip { flex: 1 1 0; text-align: center; border: 1px solid #e5e7eb; border-radius: .75rem; background: #fff; padding: .5rem .25rem; color: inherit; text-decoration: none; }
.stage-chip .n { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.stage-chip .l { font-size: .7rem; color: #6b7280; }
.stage-chip.active { border-color: var(--oxmo-primary); background: var(--bs-primary-bg-subtle); }

@media (max-width: 767.98px) {
    #sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: 100vh; width: 260px; z-index: 1060; transform: translateX(-100%); transition: transform .22s ease; }
    #sidebar .nav-link { padding: .6rem 1rem; font-size: .95rem; }
    body.drawer-open #sidebar { transform: translateX(0); box-shadow: 0 0 24px rgba(0, 0, 0, .35); }
    body.drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 1055; }
    .drawer-btn { display: inline-block; }
    #topbar { justify-content: flex-start; padding: .45rem .75rem; margin: -.75rem -.75rem .75rem; }
    #topbar .ms-drawer { margin-left: auto; }
    .app-main { padding: .75rem; }
    body.has-bottom-nav .app-main { padding-bottom: 5rem; }
    body.has-bottom-nav #bottomNav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; background: #fff; border-top: 1px solid #e5e7eb; box-shadow: 0 -2px 8px rgba(0, 0, 0, .06); padding-bottom: env(safe-area-inset-bottom); }
    #bottomNav a { flex: 1 1 0; text-align: center; padding: .45rem .15rem .4rem; color: #6b7280; text-decoration: none; font-size: .68rem; line-height: 1.15; position: relative; }
    #bottomNav a .bi { display: block; font-size: 1.3rem; margin-bottom: .1rem; }
    #bottomNav a.active { color: var(--oxmo-primary); font-weight: 600; }
    #bottomNav .badge { position: absolute; top: .25rem; left: 54%; font-size: .6rem; }
}
.order-card .oc-row { display: flex; align-items: baseline; gap: .4rem; font-size: .82rem; line-height: 1.5; }
.order-card .oc-row i { color: #9ca3af; width: 1rem; flex: none; }
.order-card .oc-row .k { color: #6b7280; width: 4.2rem; flex: none; }
.order-card .oc-row .v { color: #111827; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
/* bottom-nav labels wrap onto (up to) two lines, centred, so every item has the same height */
#bottomNav a .bl { display: block; text-align: center; min-height: 2.3em; line-height: 1.15; }
/* clear (x) button inside the type-to-search boxes */
.ss-wrap { position: relative; display: block; flex: 1 1 auto; min-width: 0; width: 100%; }
.ss-wrap .ss-input { padding-right: 2rem; }
.ss-clear { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); display: none; border: 0; background: transparent; color: #9ca3af; font-size: 1rem; line-height: 1; padding: .2rem .3rem; cursor: pointer; }
.ss-wrap.has-value .ss-clear { display: block; }
.ss-clear:hover { color: #dc2626; }
/* A page shown as a tab inside Add/Edit Masters (?embed=1): no menu, no top bar, tighter padding. */
html.embedded #sidebar, html.embedded #topbar, html.embedded #bottomNav { display: none !important; }
html.embedded .app-main { padding: 0.5rem 0.25rem; }
html.embedded .app-shell { min-height: 0; }

/* Count on a menu entry (admin: Pending Actions) */
#sidebar .nav-link { position: relative; }
#sidebar .nav-count { margin-left: auto; min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: #dc2626; color: #fff; font-size: .72rem; font-weight: 600; line-height: 1.35rem; text-align: center; }
#sidebar .nav-count.zero { background: #475569; }
#sidebar .nav-link:has(.nav-count) { display: flex; align-items: center; }
