/*
 * v4g-theme.css - the "gold" skin, rebuilt for AdminLTE 4 / Bootstrap 5
 * ======================================================================
 *
 * The app ran AdminLTE 2 with `$skin = "gold"` and loaded
 * public/admin-lte/css/skins/skin-gold.min.css. AdminLTE 4 dropped the whole skin
 * system - it themes through Bootstrap 5 CSS variables instead - so the palette is
 * reproduced here against the v4 class names.
 *
 * Colours are taken verbatim from the original skin-gold stylesheet, so the app
 * looks like it did before the upgrade:
 *
 *     header navbar        #998961   .skin-gold .main-header .navbar
 *     brand / logo         #817455   .skin-gold .main-header .logo
 *     sidebar              #406472   .skin-gold .main-sidebar
 *     sidebar section head #2f4b57 on #a7c0cb text
 *     sidebar link text    #e7eef2
 *     hover / active item  #fff on #1e282c, 3px #3c8dbc edge
 *     treeview submenu     #4d8399 with #eff4f6 text
 *     content background   #ecf0f5   (AdminLTE 2 .content-wrapper)
 *
 * Mapping of the shell classes:
 *     .main-header  -> .app-header      .main-sidebar   -> .app-sidebar
 *     .logo         -> .sidebar-brand   .content-wrapper -> .app-main
 *     .sidebar-menu > li.header -> .nav-header
 *     .treeview-menu -> .nav-treeview
 */

/* ---------------------------------------------------------------------------
 * Header
 * ------------------------------------------------------------------------- */

.app-header {
    background-color: #998961 !important;
    border-bottom: 0;
}

.app-header .nav-link,
.app-header .navbar-nav .nav-link,
.app-header .nav-item > span.nav-link {
    color: #fff;
    /* Matches the theme toggle button's own radius (a Bootstrap .btn, which
       carries var(--bs-border-radius) unconditionally) so every header icon -
       language, user menu, the sidebar hamburger - gets the same rounded
       hover/focus box that button already had. Invisible until :hover/:focus
       below paints a background to clip. */
    border-radius: var(--bs-border-radius, 6px);
}

.app-header .nav-link:hover,
.app-header .nav-link:focus {
    color: #f6f1e4;
    background-color: #8a7b57;
}

.app-header .user-image {
    height: 1.6rem;
    width: 1.6rem;
    margin-right: 0.4rem;
}

[dir="rtl"] .app-header .user-image {
    margin-right: 0;
    margin-left: 0.4rem;
}

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

.app-sidebar {
    background-color: #406472 !important;
}

/* AdminLTE 4 paints the submenu from its own variables:
 *     .sidebar-wrapper .sidebar-menu > .nav-item > .nav-treeview
 *         { background-color: var(--lte-sidebar-submenu-bg) }
 * and its default is literally `transparent`, so `.app-sidebar .nav-treeview` below
 * never showed - the submenus were see-through in both themes since the AdminLTE 4
 * migration. Setting the variable is the idiomatic fix.
 *
 * The attribute in the selector is load-bearing. The layout renders
 * `<aside class="app-sidebar" data-bs-theme="dark">` (AdminLTE's own starter markup,
 * which keeps Bootstrap components inside the rail light-on-dark), and AdminLTE ships
 * `[data-bs-theme="dark"].app-sidebar { --lte-sidebar-submenu-bg: transparent }`.
 * That is two selectors' worth of specificity and permanently beat a plain
 * `.app-sidebar`, in light mode too. Matching the attribute levels the score, and
 * loading after AdminLTE wins it.
 *
 * The plain `.app-sidebar .nav-treeview` rules are still needed: AdminLTE's variable
 * only reaches a submenu that is a direct child of a top-level item, so the third
 * level under Asset Management is styled by those selectors alone. */
.app-sidebar[data-bs-theme] {
    --lte-sidebar-submenu-bg: #4d8399;
    --lte-sidebar-submenu-color: #eff4f6;
    --lte-sidebar-submenu-hover-bg: #3d6b7d;
    --lte-sidebar-submenu-hover-color: #fff;
    /* Selected submenu item takes the same dark fill as a top-level one - see
       "Selected item". */
    --lte-sidebar-submenu-active-bg: #1e282c;
    --lte-sidebar-submenu-active-color: #fff;

    /* AdminLTE draws the hover/active lift from these, from a selector one class more
       specific than anything reasonable to write here, so `.nav-link.active
       { background-color: ... }` never applied. Hover keeps the translucent lift;
       the selected item is opaque, so the current page reads the same whether it is
       a top-level entry or buried three levels down. */
    --lte-sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    --lte-sidebar-menu-active-bg: #1e282c;
}

.app-sidebar .sidebar-brand {
    background-color: #817455;
    border-bottom: 0;
}

.app-sidebar .sidebar-brand .brand-link,
.app-sidebar .sidebar-brand .brand-text {
    color: #fff;
}

.app-sidebar .sidebar-menu .nav-link {
    color: #e7eef2;
    /* Same rounded hover/focus box as the header icons - see .app-header
       .nav-link above. Was flat (0) to match the full-bleed AdminLTE 2 rail
       highlight; the corners only show once the hover/active background below
       paints something for them to clip. */
    border-radius: var(--bs-border-radius, 6px);
}

.app-sidebar .sidebar-menu .nav-link:hover,
.app-sidebar .sidebar-menu .nav-link:focus {
    color: #fff;
    background-color: #1e282c;
    border-inline-end: 3px solid #3c8dbc;
}

/* Selected item: the page you are actually on, at whatever depth it sits.
 *
 * One treatment for all depths. A selected submenu entry used to get the treeview's
 * own hover tone (#3d6b7d) while a top-level one got a dark fill, so the same "you
 * are here" state was drawn differently depending on where it sat in the tree.
 *
 * The fill is the dark tone the rail has always used for this state. The edge is the
 * header's colour, which ties the current page to the top bar and keeps the marker
 * inside the palette the theme already picked rather than adding one of its own -
 * hover keeps the blue edge, so the two states stay distinct.
 *
 * Only the leaf carries .active - the layout's sidebar script marks the matched link
 * and gives its ancestors .menu-open alone, so a parent stays expanded but keeps
 * AdminLTE's ordinary open-branch styling. Styling `.menu-open` here would fight
 * that, and would also catch a branch the user merely expanded by hand. */
.app-sidebar .sidebar-menu .nav-link.active,
.app-sidebar .sidebar-menu > .nav-item > .nav-link.active,
.app-sidebar .nav-treeview .nav-link.active,
.app-sidebar .nav-treeview .nav-treeview .nav-link.active {
    color: #fff;
    background-color: #1e282c;
    border-inline-end: 3px solid #998961;
}

/* Section headings ("System", "Main Menu") */
.app-sidebar .nav-header {
    color: #a7c0cb;
    background: #2f4b57;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    /* Same treatment as the nav-link boxes above. These run the full width of
       the rail, unlike a header icon or a menu item, so rounding shows as a
       small inset at each corner rather than a floating pill - the sidebar's
       own background comes through underneath, the same way the dashboard
       widgets show their page background through a rounded corner. */
    border-radius: var(--bs-border-radius, 6px);
}

/* Nested menus */
.app-sidebar .nav-treeview {
    background: #4d8399;
    margin-bottom: 1px;
}

.app-sidebar .nav-treeview .nav-link {
    color: #eff4f6;
    border-radius: var(--bs-border-radius, 6px);
}

/* Hover only - the selected state is set above and must not be repeated here, or
   this rule would win on load order and put the teal back under the current page. */
.app-sidebar .nav-treeview .nav-link:hover {
    color: #fff;
    background-color: #3d6b7d;
}

/* A third level exists under Asset Management. */
.app-sidebar .nav-treeview .nav-treeview {
    background: #44758a;
}

/* ---------------------------------------------------------------------------
 * Content area
 * AdminLTE 2 used #ecf0f5 behind the page, which is what the cards were designed
 * against. bg-body-tertiary on <body> would otherwise give a near-white page.
 * ------------------------------------------------------------------------- */

body.layout-fixed,
.app-main {
    background-color: #ecf0f5;
}

/* The footer picks up a muted tone of the gold header rather than plain white,
   so the page is bookended by the brand colour. */
.app-footer {
    background-color: #e8e1d3;
    border-top: 1px solid #cfc6b3;
    color: #4a4438;
}

.app-footer a { color: #3c6478; }

/* Cards keep the AdminLTE 2 look: white panel with a coloured top edge. */
.app-main .card,
.app-main .panel,
.app-main .box {
    border-top: 3px solid #3c8dbc;
    border-radius: 0.25rem;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.app-main .card > .card-header {
    border-bottom: 1px solid #f4f4f4;
    background: transparent;
}

/* ---------------------------------------------------------------------------
 * AdminLTE 2 colour helpers
 *
 * The views carry ~450 of these (bg-navy 87, bg-gray 87, bg-green 39, bg-red 35,
 * bg-orange 32, bg-blue 32, bg-yellow 28, bg-aqua 18, bg-maroon 17, bg-olive 16,
 * bg-teal 5, plus the text-* variants). Bootstrap 5 defines none of them except
 * bg-black, so every one of those elements lost its colour on upgrade - which is
 * why the announcement banner came out a harsh default blue instead of AdminLTE's
 * softer #0073b7. Values are copied verbatim from the AdminLTE 2 stylesheet.
 * ------------------------------------------------------------------------- */

.bg-light-blue, .bg-light-blue-active { background-color: #3c8dbc !important; color: #fff; }
.bg-aqua,   .bg-aqua-active   { background-color: #00c0ef !important; color: #fff; }
.bg-blue,   .bg-blue-active   { background-color: #0073b7 !important; color: #fff; }
.bg-navy,   .bg-navy-active   { background-color: #001f3f !important; color: #fff; }
.bg-teal,   .bg-teal-active   { background-color: #39cccc !important; color: #fff; }
.bg-olive,  .bg-olive-active  { background-color: #3d9970 !important; color: #fff; }
.bg-green,  .bg-green-active  { background-color: #00a65a !important; color: #fff; }
.bg-lime,   .bg-lime-active   { background-color: #01ff70 !important; color: #000; }
.bg-orange, .bg-orange-active { background-color: #ff851b !important; color: #fff; }
.bg-yellow, .bg-yellow-active { background-color: #f39c12 !important; color: #fff; }
.bg-fuchsia,.bg-fuchsia-active{ background-color: #f012be !important; color: #fff; }
.bg-purple, .bg-purple-active { background-color: #605ca8 !important; color: #fff; }
.bg-maroon, .bg-maroon-active { background-color: #d81b60 !important; color: #fff; }
.bg-red,    .bg-red-active    { background-color: #dd4b39 !important; color: #fff; }
.bg-gray                      { background-color: #d2d6de !important; color: #000; }

.text-light-blue { color: #3c8dbc !important; }
.text-aqua   { color: #00c0ef !important; }
.text-blue   { color: #0073b7 !important; }
.text-navy   { color: #001f3f !important; }
.text-teal   { color: #39cccc !important; }
.text-olive  { color: #3d9970 !important; }
.text-green  { color: #00a65a !important; }
.text-orange { color: #ff851b !important; }
.text-yellow { color: #f39c12 !important; }
.text-purple { color: #605ca8 !important; }
.text-maroon { color: #d81b60 !important; }
.text-red    { color: #dd4b39 !important; }

/* A coloured button keeps white text and a matching hover. */
.btn.bg-blue:hover, .btn.bg-green:hover, .btn.bg-red:hover, .btn.bg-navy:hover,
.btn.bg-yellow:hover, .btn.bg-aqua:hover, .btn.bg-orange:hover, .btn.bg-purple:hover,
.btn.bg-maroon:hover, .btn.bg-olive:hover, .btn.bg-teal:hover {
    filter: brightness(0.92);
    color: #fff;
}

/* ---------------------------------------------------------------------------
 * AdminLTE 2 components still used by the page markup
 * box-* (500+ uses), info-box (293), small-box (55), callout (18).
 * AdminLTE 4 replaced these with cards, so they are reproduced here.
 * ------------------------------------------------------------------------- */

.box-header {
    display: block;
    padding: 10px;
    position: relative;
    border-bottom: 1px solid #f4f4f4;
}

.box-header .box-title {
    display: inline-block;
    margin: 0;
    font-size: 18px;
    line-height: 1;
}

.box-body  { padding: 10px; }
.box-footer {
    padding: 10px;
    background-color: #fff;
    border-top: 1px solid #f4f4f4;
}

.info-box {
    display: flex;
    align-items: stretch;
    min-height: 90px;
    margin-bottom: 15px;
    background: #fff;
    /* 6x the original 2px - tried on the dashboard first, then promoted here to
       apply everywhere .info-box appears (business intelligence, invoice lists).
       overflow:hidden clips the icon block to the curve instead of matching its
       own corner radius by hand, and is correct in RTL for free. */
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.info-box-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90px;
    font-size: 45px;
    line-height: 90px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px 0 0 2px;
}

.info-box-content {
    flex: 1;
    padding: 5px 10px;
}

.info-box-text, .info-box-number { display: block; }
.info-box-text   { font-size: 14px; text-transform: uppercase; }
.info-box-number { font-size: 18px; font-weight: bold; }
.info-box-more   { display: block; font-size: 13px; }

.small-box {
    position: relative;
    display: block;
    margin-bottom: 20px;
    /* 6x the original 2px - see .info-box above, same reasoning and same
       promotion from a dashboard-only trial to every page. */
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.small-box > .inner { padding: 10px; }
.small-box h3 { margin: 0 0 10px 0; font-size: 38px; font-weight: bold; white-space: nowrap; }
.small-box p  { margin: 0; font-size: 15px; }

/* The footer follows the box's own text colour rather than assuming white.
 * AdminLTE 2 small-boxes were always dark-on-light-text, so a hardcoded white was
 * safe there; a Bootstrap `text-bg-*` surface picks its foreground per colour and
 * uses black on the lighter ones, where a white footer measured 1.95:1. */
.small-box > .small-box-footer {
    position: relative;
    display: block;
    padding: 3px 0;
    color: inherit;
    opacity: .85;
    text-align: center;
    text-decoration: none;
    background: rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.small-box > .small-box-footer:hover { opacity: 1; background: rgba(0, 0, 0, 0.15); }

.small-box .icon {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 0;
    font-size: 70px;
    color: rgba(0, 0, 0, 0.15);
}

[dir="rtl"] .small-box .icon { right: auto; left: 10px; }

/* ===========================================================================
 * Dashboard widget row - a size/colour variant, scoped to the dashboard only
 *
 * The two "User Details" / "System Details" cards and the three stat counters
 * are built from the same .info-box / .small-box components used elsewhere in
 * the app (business intelligence, invoice lists), just tuned for this specific
 * row: taller, and with the info-box content vertically centred so two boxes
 * with a different number of lines still look balanced.
 *
 * The roundedness increase that started here has since been promoted to the
 * base .info-box/.small-box rules above, so it is no longer repeated here.
 * What stays scoped to .dashboard-widgets is page-specific presentation - the
 * taller sizing, the two info-box colours and the plain icon treatment - not
 * something implied by "roundedness, applied everywhere".
 * ------------------------------------------------------------------------- */
.dashboard-widgets .info-box {
    min-height: 140px;
}

.dashboard-widgets .info-box-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Names, e-mail addresses and dates should not be shouted in caps. */
.dashboard-widgets .info-box-text {
    text-transform: none;
}

/* User Details / System Details: distinct, mid-toned fills instead of the
 * saturated text-bg-info / text-bg-warning pair - the latter read as the same
 * colour as the "Total Clients" stat box below it (both warning-orange).
 *
 * History, each step mix(previous, white, 25%), not a flat +25 per channel:
 *   1. #dbe9f6 / #ece3f7 - too light, and the lavender read as pink not purple
 *   2. #537480 / #6d4a96 - the sidebar's own teal (#406472, see the "gold"
 *      skin notes elsewhere in this file) and a genuine purple, white text -
 *      too dark the other way
 *   3. #7e97a0 / #9277b0 - white text no longer cleared AA at this lightness
 *      (3.08:1 / 3.83:1), so text and icon moved to near-black (#1a1a1a)
 *   4. current: #9eb1b8 / #ad99c4, one more 25%-toward-white step. The
 *      near-black text/icon from step 3 still applies and now reads better
 *      for it - 7.82:1 / 6.74:1 text, 5.32:1 / 4.78:1 icon at 0.8 opacity. */
.dashboard-widgets .info-box.dash-info-user {
    background: #c6d3d7;
    color: #1a1a1a;
}

.dashboard-widgets .info-box.dash-info-system {
    background: #d6c2be;
    color: #1a1a1a;
}

/* A plain, small icon rather than the AdminLTE2 dark icon block
 * (.info-box-icon) - the block reads as loud next to these fills, and
 * competed with the coloured icons in the stat row below. No background of its
 * own, so no radius/RTL handling is needed for it either. */
.dashboard-widgets .info-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    font-size: 30px;
    color: rgba(26, 26, 26, 0.8);
}

.dashboard-widgets .small-box > .inner {
    padding: 20px 18px;
}

.dashboard-widgets .small-box .small-box-icon {
    font-size: 85px;
    top: 18px;
}

.dashboard-widgets .small-box > .small-box-footer {
    padding: 6px 0;
}

/* Expiring Items card body: the chart and the tabbed table sit side by side
 * only at md+, where a fixed 300px fits both. Below md they stack, so the fixed
 * height is dropped there - it would cut the table off mid-row and, before this
 * rule existed, the overflow spilled past the card and over the footer.
 *
 * `hidden`, not `auto`. With auto this card grew a second scrollbar of its own,
 * wrapped around the one the table already has: the contents came to 302px against
 * a 300px box, so it scrolled by two pixels - a full-height scrollbar for two
 * pixels of nothing, right beside the table's own. The table region scrolls (it has
 * its own max-height), which is the scrollbar that means something; this one only
 * ever hid a rounding overflow, so it is clipped instead. Below md there is no fixed
 * height, so nothing is clipped there either. */
.dashboard-expiring-body {
    overflow: hidden;
}

@media (min-width: 768px) {
    .dashboard-expiring-body {
        height: 300px;
    }
}

.callout {
    padding: 15px 30px 15px 15px;
    margin-bottom: 20px;
    border-left: 5px solid #eee;
    border-radius: 3px;
    color: #fff;
    background-color: #f0f0f0;
}

.callout h4 { margin-top: 0; font-weight: 600; }
.callout p:last-child { margin-bottom: 0; }
.callout.callout-danger  { background-color: #dd4b39 !important; border-color: #d73925; }
.callout.callout-warning { background-color: #f39c12 !important; border-color: #e08e0b; }

/* callout-warning takes DARK text, in both themes.
 *
 * Its amber (#f39c12) is a light surface, so the blanket
 * `[data-bs-theme="dark"] .callout *` rule - right for callout-info, -danger and -success,
 * which are all saturated - put white on it at 2.19:1. Measured, not assumed. Dark text
 * gives 6.7:1 on the same fill, and is what light mode already renders, so pinning it for
 * both themes also stops the two disagreeing.
 *
 * Specificity: (0,3,0) with the theme attribute, so it beats both `.callout.callout-warning`
 * and the blanket dark rule, which are (0,2,0). Same approach as bi-daterange-callout
 * below - see the note there. */
.callout.callout-warning,
.callout.callout-warning *,
[data-bs-theme="dark"] .callout.callout-warning,
[data-bs-theme="dark"] .callout.callout-warning * {
    color: #212529;
}
.callout.callout-info    { background-color: #00c0ef !important; border-color: #00a7d0; }
.callout.callout-success { background-color: #00a65a !important; border-color: #008d4c; }

[dir="rtl"] .callout {
    padding: 15px 15px 15px 30px;
    border-left: 0;
    border-right: 5px solid #eee;
}

/* ---------------------------------------------------------------------------
 * Contextual palette: keep Bootstrap 3's colours
 *
 * Bootstrap 5 brightened every contextual colour, most visibly primary
 * (#337ab7 -> #0d6efd). Since this app's markup and imagery were all designed
 * against the Bootstrap 3 palette, the old values are restored here so buttons,
 * alerts and badges look as they did. The dashboard announcement banner is the
 * clearest example: it renders as `alert bg-primary`, and under BS5's default it
 * came out a harsh royal blue instead of the original muted steel blue.
 *
 * Values are lifted from the Bootstrap 3.3.6 stylesheet the app used to ship.
 * ------------------------------------------------------------------------- */

:root {
    --bs-primary: #337ab7;
    --bs-primary-rgb: 51, 122, 183;
    --bs-success: #5cb85c;
    --bs-success-rgb: 92, 184, 92;
    --bs-info: #5bc0de;
    --bs-info-rgb: 91, 192, 222;
    --bs-warning: #f0ad4e;
    --bs-warning-rgb: 240, 173, 78;
    --bs-danger: #d9534f;
    --bs-danger-rgb: 217, 83, 79;
    --bs-link-color: #337ab7;
    --bs-link-hover-color: #23527c;
}

/* ---------------------------------------------------------------------------
 * text-bg-* foregrounds, recomputed for the palette above
 *
 * Bootstrap resolves the foreground of `.text-bg-*` at build time, against its
 * own palette, and bakes the answer in as `color: #fff !important`. Re-pinning
 * --bs-*-rgb above changes the background but cannot change that baked value, so
 * the lighter Bootstrap 3 surfaces ended up with white text on them: measured
 * 2.48:1 on --bs-success (#5cb85c) and 1.9:1 on --bs-info (#5bc0de).
 *
 * Black is what Bootstrap itself picks for surfaces this light - it already does
 * so for warning - and gives 8.5:1 and 10:1 respectively. The other three are
 * dark enough to keep white and are left alone.
 * ------------------------------------------------------------------------- */
.text-bg-success,
.text-bg-info {
    color: #000 !important;
}

/* Buttons: Bootstrap 5 reads these per-component variables, not --bs-primary. */
.btn-primary { --bs-btn-bg: #337ab7; --bs-btn-border-color: #2e6da4; --bs-btn-hover-bg: #286090; --bs-btn-hover-border-color: #204d74; --bs-btn-active-bg: #204d74; }
.btn-success { --bs-btn-bg: #5cb85c; --bs-btn-border-color: #4cae4c; --bs-btn-hover-bg: #449d44; --bs-btn-hover-border-color: #398439; --bs-btn-active-bg: #398439; }
.btn-info    { --bs-btn-bg: #5bc0de; --bs-btn-border-color: #46b8da; --bs-btn-hover-bg: #31b0d5; --bs-btn-hover-border-color: #269abc; --bs-btn-active-bg: #269abc; --bs-btn-color: #fff; --bs-btn-hover-color: #fff; }
.btn-warning { --bs-btn-bg: #f0ad4e; --bs-btn-border-color: #eea236; --bs-btn-hover-bg: #ec971f; --bs-btn-hover-border-color: #d58512; --bs-btn-active-bg: #d58512; --bs-btn-color: #fff; --bs-btn-hover-color: #fff; }
.btn-danger  { --bs-btn-bg: #d9534f; --bs-btn-border-color: #d43f3a; --bs-btn-hover-bg: #c9302c; --bs-btn-hover-border-color: #ac2925; --bs-btn-active-bg: #ac2925; }

/* The brand button, used for Sign in. It came from AdminLTE 2's stylesheet,
   which the login page no longer loads now that those views are on Bootstrap 5
   (see front_partials/styles) - without this the Sign in button would fall back
   to an unstyled .btn. Colours are AdminLTE 2's, except the border, which was
   #e08e0b there: an orange that belongs to btn-warning directly above it in that
   file and reads as a stray copy-paste against this gold. The brand tone the
   sidebar already uses is taken instead. The installer keeps its own copy of
   .btn-gold in installer_AdminLTE.min.css and is unaffected. */
.btn-gold {
    --bs-btn-color: #fff;
    --bs-btn-bg: #998961;
    --bs-btn-border-color: #817455;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #6b6451;
    --bs-btn-hover-border-color: #6b6451;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #5c5647;
    --bs-btn-active-border-color: #5c5647;
}

/* ===========================================================================
 * The signed-out panel (login, password reset, password email, 404)
 *
 * These four views are on layouts/front_master, outside .app-main, so the card
 * rules further up this file do not reach them - deliberately, since the blue
 * top edge those add belongs to the application chrome, not to a login screen.
 * That leaves Bootstrap's default 0.375rem, so the radius is restated here to
 * the 12px the rest of the app settled on (see the .info-box note above).
 *
 * .panel is included because the two password views are still Bootstrap 3
 * markup shimmed by bs5-compat; without it they would round differently from
 * the login card sitting in the same frame.
 *
 * overflow: hidden matters: .login-card-body paints its own background, and a
 * square-cornered fill drawn over a rounded parent squares the corners back
 * off. Clipping to the curve is the same fix .info-box uses.
 * ------------------------------------------------------------------------- */
.login-box .card,
.login-box .panel {
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* ===========================================================================
 * Help and Tutorials
 *
 * Long-form prose, so the rules here are mostly about reading comfort: a
 * measure that does not run the full width of a wide monitor, and enough space
 * between a question and the answer under it to tell them apart at a glance.
 *
 * Logical properties throughout (padding-inline-start, border-inline-start,
 * margin-inline-end) so the page mirrors for Arabic without a second RTL block.
 * ------------------------------------------------------------------------- */

.help-search { max-width: 46rem; }
.help-search .form-label { font-weight: 600; margin-bottom: 0.35rem; }

.help-search-status {
    min-height: 1.25rem;
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--bs-secondary-color, #6c757d);
}

.help-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

/* Contents grid. auto-fill rather than a fixed column count so the 17 sections
   reflow from one column on a phone up to four on a wide screen. */
.help-contents {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 0.5rem;
}

.help-contents-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
    transition: background-color .12s ease-in-out, border-color .12s ease-in-out;
}

.help-contents-item:hover,
.help-contents-item:focus-visible {
    background-color: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.18);
    color: inherit;
    text-decoration: none;
}

.help-contents-item > .fa {
    width: 1.1rem;
    text-align: center;
    color: #3c6478;
}

.help-contents-title { flex: 1 1 auto; }

.help-contents-count {
    flex: 0 0 auto;
    min-width: 1.6rem;
    padding: 0 0.4rem;
    font-size: 0.75rem;
    line-height: 1.5rem;
    text-align: center;
    border-radius: 999px;
    background-color: rgba(0, 0, 0, 0.07);
    color: var(--bs-secondary-color, #6c757d);
}

/* The "back to contents" link rides in the card header opposite the title.
   float, not absolute positioning, because .card-header here is not a flex
   container and an absolutely placed link overlaps a title that wraps. */
.help-back-link {
    float: inline-end;
    font-size: 0.8rem;
    font-weight: normal;
    text-decoration: none;
}

.help-section-intro { max-width: 60rem; }

.help-topic {
    padding: 0.6rem 0;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.help-topic:first-of-type { border-top: 0; }

.help-topic-q {
    cursor: pointer;
    font-weight: 600;
    padding: 0.35rem 0.5rem;
    border-radius: 12px;
    list-style: none;              /* Chrome/Safari */
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.help-topic-q::-webkit-details-marker { display: none; }

.help-topic-q:hover { background-color: rgba(0, 0, 0, 0.04); }

/* Own disclosure triangle, since the native marker is suppressed above so that
   it can be positioned and rotated consistently across browsers.

   Drawn with borders rather than set as an icon-font glyph. It used to be
   `content: "\f105"` in `font-family: FontAwesome` - the Font Awesome FOUR family
   name - but the web UI loads Font Awesome 5, which registers only "Font Awesome
   5 Free" and "Font Awesome 5 Brands". (v4-shims maps the old CLASS names, not
   the old family name, and the FA4 files under components/font-awesome are loaded
   only by the print and installer stacks.) So the family never resolved, the
   browser fell back to a system font, and U+F105 is in the Private Use Area with
   no glyph there - which renders as an empty box. It showed up on Android first
   because a desktop is likelier to have something mapped at that codepoint.

   Borders need no font at all, so this cannot come back. It also gets RTL for
   free: border-inline-start is the left edge in LTR (triangle points right) and
   the right edge in RTL (points left), so no second content rule is needed.
   currentColor keeps the dark-mode override below working. */
.help-topic-q::before {
    content: "";
    flex: 0 0 auto;
    width: 0;
    height: 0;
    align-self: center;            /* the row aligns on the baseline; an empty box has none */
    margin-inline-end: 0.1rem;
    border-block-start: 0.32rem solid transparent;
    border-block-end: 0.32rem solid transparent;
    border-inline-start: 0.42rem solid currentColor;
    color: #3c6478;
    transition: transform .15s ease-in-out;
}

.help-topic[open] > .help-topic-q::before { transform: rotate(90deg); }
[dir="rtl"] .help-topic[open] > .help-topic-q::before { transform: rotate(-90deg); }

.help-topic-a {
    max-width: 60rem;
    padding-inline-start: 1.75rem;
    padding-top: 0.35rem;
    border-inline-start: 2px solid rgba(60, 100, 120, 0.25);
    margin-inline-start: 0.75rem;
}

.help-topic-a p:last-child,
.help-topic-a ul:last-child,
.help-topic-a ol:last-child { margin-bottom: 0; }

.help-topic-a li { margin-bottom: 0.3rem; }

/* Dark mode: the hairlines and tinted fills above are black-on-light, which
   disappears against a dark card. Same shapes, inverted. */
[data-bs-theme="dark"] .help-contents-item { border-color: rgba(255, 255, 255, 0.14); }

[data-bs-theme="dark"] .help-contents-item:hover,
[data-bs-theme="dark"] .help-contents-item:focus-visible {
    background-color: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.28);
}

[data-bs-theme="dark"] .help-contents-count { background-color: rgba(255, 255, 255, 0.12); }
[data-bs-theme="dark"] .help-topic { border-top-color: rgba(255, 255, 255, 0.1); }
[data-bs-theme="dark"] .help-topic-q:hover { background-color: rgba(255, 255, 255, 0.07); }
[data-bs-theme="dark"] .help-contents-item > .fa,
[data-bs-theme="dark"] .help-topic-q::before { color: #8fb8cc; }
[data-bs-theme="dark"] .help-topic-a { border-inline-start-color: rgba(143, 184, 204, 0.35); }

/* The English title is 33 characters at x-large, which lands a few pixels over
   the 400px .login-box and so broke onto a second line. It sat on one line,
   slightly wider than the panel, before the stack changed - the overflow is the
   original look, not an accident. Released below 576px, where the viewport
   itself is the constraint and overflowing would mean a sideways scroll. */
.login-box .login-logo { white-space: nowrap; }

@media (max-width: 575.98px) {
    .login-box .login-logo { white-space: normal; }
}

/* Same red as .btn-danger above, not Bootstrap 5's own #dc3545 - so the user
   menu's outlined Sign out button fills the same colour on hover that every
   other danger button in the app already uses. */
.btn-outline-danger { --bs-btn-color: #d9534f; --bs-btn-border-color: #d9534f; --bs-btn-hover-bg: #d9534f; --bs-btn-hover-border-color: #d9534f; --bs-btn-active-bg: #c9302c; --bs-btn-active-border-color: #ac2925; }

/* Bootstrap 3's .bg-* contextual helpers (the announcement banner uses bg-primary). */
.bg-primary { background-color: #337ab7 !important; color: #fff; }
.bg-success { background-color: #dff0d8 !important; }
.bg-info    { background-color: #d9edf7 !important; }
.bg-warning { background-color: #fcf8e3 !important; }
.bg-danger  { background-color: #f2dede !important; }

/* An "alert bg-*" banner needs light text on the solid fill. */
.alert.bg-primary, .alert.bg-primary a { color: #fff; }
.alert.bg-primary a { text-decoration: underline; }

/* The dashboard announcement's dismiss X. btn-close-white already inverts the
   glyph to white, but Bootstrap rests .btn-close at opacity .5, which on this
   saturated blue reads as a faint grey smudge rather than a control. Lifted to
   .75 at rest and full on hover/focus - still secondary to the message, but
   legible enough to be found. */
.alert.bg-primary .btn-close { opacity: 0.75; }
.alert.bg-primary .btn-close:hover,
.alert.bg-primary .btn-close:focus { opacity: 1; }

/* ---------------------------------------------------------------------------
 * Card / box top-edge colours per variant, as AdminLTE 2 had them.
 * (box box-primary 111 uses, box-default 63, box-success 9, box-warning 8,
 *  box-info 7, box-danger 3)
 * ------------------------------------------------------------------------- */

.app-main .box.box-primary,  .app-main .panel-primary  { border-top-color: #3c8dbc; }
.app-main .box.box-info,     .app-main .panel-info     { border-top-color: #00c0ef; }
.app-main .box.box-danger,   .app-main .panel-danger   { border-top-color: #dd4b39; }
.app-main .box.box-warning,  .app-main .panel-warning  { border-top-color: #f39c12; }
.app-main .box.box-success,  .app-main .panel-success  { border-top-color: #00a65a; }
.app-main .box.box-default,  .app-main .panel-default  { border-top-color: #d2d6de; }
.app-main .box.box-yellow                              { border-top-color: #f39c12; }

/* ---------------------------------------------------------------------------
 * AdminLTE 4 cards, aligned to the same palette
 *
 * `.card.card-outline` draws `3px solid var(--lte-card-variant-bg)` along the top,
 * which is the same idiom as the `box-*` accents above - so an AdminLTE 4 card is
 * a drop-in replacement for an AdminLTE 2 box. AdminLTE 4 hardcodes Bootstrap 5's
 * brighter palette into those variant tokens (#0d6efd for primary), which would
 * put a card next to a box in two different blues. Re-pointing the tokens at the
 * values already used above keeps a converted card indistinguishable from the
 * boxes around it.
 *
 * Only the accent is re-pinned. `--lte-card-variant-color` is left as AdminLTE
 * ships it, since it is chosen for contrast against the accent (black on the
 * light warning/info tones, white on the darker ones) and these replacements sit
 * at a similar lightness.
 * ------------------------------------------------------------------------- */
.card.card-primary   { --lte-card-variant-bg: #3c8dbc; }
.card.card-info      { --lte-card-variant-bg: #00c0ef; }
.card.card-danger    { --lte-card-variant-bg: #dd4b39; }
.card.card-warning   { --lte-card-variant-bg: #f39c12; }
.card.card-success   { --lte-card-variant-bg: #00a65a; }
.card.card-secondary { --lte-card-variant-bg: #d2d6de; }

/* AdminLTE 4 pins the small-box icon to the right; mirror it in Arabic, the way
   the AdminLTE 2 `.small-box .icon` rule further up already is. */
[dir="rtl"] .small-box .small-box-icon { right: auto; left: 15px; }

/* ===========================================================================
 * Theme modes
 *
 * Everything above assumes the light theme, because that is what this product
 * has always been. These rules make the two modes explicit:
 *
 *   - color-scheme is declared for BOTH themes. Bootstrap 5.3 only declares
 *     `color-scheme: dark` for [data-bs-theme=dark] and says nothing for light, so
 *     on a dark-mode desktop the browser rendered every unstyled control - bare
 *     <input>, <textarea>, <select>, native date pickers, scrollbars - in its dark
 *     styling while the page around them stayed light.
 *   - The light-only surfaces above are re-stated for dark, so switching the theme
 *     produces a deliberate dark UI instead of light panels with light text.
 *
 * The gold header and slate sidebar keep their hue in both modes - they are the
 * product's identity - but dark mode takes each one two shades down, so the chrome
 * sits with the dark surfaces instead of glowing against them. See "Dark mode
 * chrome" below.
 * =========================================================================== */

:root,
[data-bs-theme="light"] {
    color-scheme: light;
}

[data-bs-theme="dark"] {
    color-scheme: dark;
}

/* Plugin stylesheets pushed through @extraStyles load *after* this file, so a bare
   `body { color: ... }` in one of them wins on order. components/jquery-orgchart's
   style.css does exactly that (`body { font-family: Arial; color: #333333 }`), which
   dragged the Chart of Accounts headings to #333 - unreadable on the dark surface,
   since h1-h6 take --bs-heading-color, which resolves to `inherit`.

   `html body` is one selector more specific than a bare `body`, so it wins whatever
   the load order, and hands the colour back to the active theme. */
html body {
    color: var(--bs-body-color);
}

/* --- Light mode surfaces (scoped so dark mode can override) --------------- */

[data-bs-theme="light"] body.layout-fixed,
[data-bs-theme="light"] .app-main {
    background-color: #ecf0f5;
}

/* .app-footer is deliberately NOT in this list. It carries the muted gold above, and
   listing it here at two selectors' worth of specificity overrode that and painted the
   footer plain white - the page lost the brand colour at its bottom edge. .box-footer
   is a card's own footer and does belong with the white surfaces. */
[data-bs-theme="light"] .app-main .card,
[data-bs-theme="light"] .app-main .panel,
[data-bs-theme="light"] .app-main .box,
[data-bs-theme="light"] .info-box,
[data-bs-theme="light"] .box-footer {
    background-color: #fff;
}

/* Headings and body copy: AdminLTE 2 used #333/#444 rather than pure black. */
[data-bs-theme="light"] .app-main,
[data-bs-theme="light"] .content-header,
[data-bs-theme="light"] .box-title,
[data-bs-theme="light"] .app-main h1,
[data-bs-theme="light"] .app-main h2,
[data-bs-theme="light"] .app-main h3,
[data-bs-theme="light"] .app-main h4,
[data-bs-theme="light"] .app-main h5 {
    color: #333;
}

/* ...except on a surface that carries its own colour.
 *
 * A small-box paints a saturated background and sets `color: #fff` on itself,
 * expecting its contents to inherit. The heading rule above is (0,2,1) and beats
 * that inheritance, so the widget's headline number rendered #333 on the box's
 * blue - measured 2.6:1, effectively unreadable - while the caption beside it
 * stayed white. The `> small` rule further down did the same at #777.
 *
 * Both are answered here rather than by weakening the rules above, which are
 * right for ordinary page headings. The attribute selector lifts these to (0,3,1)
 * so they win in either theme.
 */
[data-bs-theme] .app-main .small-box .h3,
[data-bs-theme] .app-main .small-box h3,
[data-bs-theme] .app-main .small-box h3 > small,
[data-bs-theme] .app-main .small-box p {
    color: inherit;
}

/* --- Dark mode surfaces --------------------------------------------------- */

[data-bs-theme="dark"] body.layout-fixed,
[data-bs-theme="dark"] .app-main {
    background-color: #1b1f22;
}

[data-bs-theme="dark"] .app-main .card,
[data-bs-theme="dark"] .app-main .panel,
[data-bs-theme="dark"] .app-main .box,
[data-bs-theme="dark"] .info-box,
[data-bs-theme="dark"] .box-footer,
[data-bs-theme="dark"] .app-footer,
[data-bs-theme="dark"] .well {
    background-color: #2b3035;
    border-color: #3a4046;
}

[data-bs-theme="dark"] .box-header,
[data-bs-theme="dark"] .box-footer,
[data-bs-theme="dark"] .app-main .card > .card-header {
    border-color: #3a4046;
}

[data-bs-theme="dark"] .app-footer {
    color: #dee2e6;
    border-top-color: #3a4046;
}

/* The nav-tabs-custom wrapper is a card, so its tab strip follows the theme. */
[data-bs-theme="dark"] .nav-tabs-custom > .nav-tabs {
    border-bottom-color: #3a4046;
}

/* --- Dark mode chrome -----------------------------------------------------
 * The header and sidebar keep their hue but drop seven shades in dark mode, so the
 * gold bar and slate rail stop glowing against the dark content area. Every value
 * is the light one mixed with 60% black, which keeps the palette recognisably the
 * same skin and lifts the text contrast well clear (8.9-14.7:1, up from 3.4-5.5:1
 * in light mode).
 *
 *     header navbar        #998961 -> #3d3727
 *     header link hover    #8a7b57 -> #373123
 *     brand / logo         #817455 -> #342e22
 *     sidebar              #406472 -> #1a282e
 *     sidebar section head #2f4b57 -> #131e23
 *     treeview submenu     #4d8399 -> #1f343d
 *     hover / active item  #1e282c -> #182023
 *
 * !important mirrors the base rules for .app-header and .app-sidebar, which need it
 * to win against AdminLTE's own backgrounds.
 * ------------------------------------------------------------------------- */

[data-bs-theme="dark"] .app-header {
    background-color: #3d3727 !important;

    /* At this darkness the chrome is close to the page itself - the rail sits at
       1.10:1 against the #1b1f22 content area, where at two shades it was 1.93:1 - so
       a hairline keeps the edges of the shell readable. Drop these two rules if the
       chrome should blend into the page instead. */
    border-bottom: 1px solid #4b442f;
}

[data-bs-theme="dark"] .app-header .nav-link:hover,
[data-bs-theme="dark"] .app-header .nav-link:focus {
    background-color: #373123;
}

[data-bs-theme="dark"] .app-sidebar {
    background-color: #1a282e !important;
    border-inline-end: 1px solid #24363e;
}

/* Same variables as the light block, two shades down. The trailing attribute keeps
   this above AdminLTE's [data-bs-theme="dark"].app-sidebar - see the note there. */
[data-bs-theme="dark"] .app-sidebar[data-bs-theme] {
    --lte-sidebar-submenu-bg: #1f343d;
    --lte-sidebar-submenu-hover-bg: #182b32;
    --lte-sidebar-submenu-active-bg: #182023;

    /* The lift darkens rather than lightens, so it reads the same way against the
       darker rail. The selected item stays opaque here too. */
    --lte-sidebar-hover-bg: rgba(0, 0, 0, 0.25);
    --lte-sidebar-menu-active-bg: #182023;
}

[data-bs-theme="dark"] .app-sidebar .sidebar-brand {
    background-color: #342e22;
}

[data-bs-theme="dark"] .app-sidebar .nav-header {
    background: #131e23;
}

[data-bs-theme="dark"] .app-sidebar .nav-treeview {
    background: #1f343d;
}

/* Nested menus follow, or a submenu would sit lighter than the rail it opens from.
   The third level exists under Asset Management. Hover only; the selected state is
   the block below, which must load after this to keep it. */
[data-bs-theme="dark"] .app-sidebar .nav-treeview .nav-link:hover {
    background-color: #182b32;
}

/* Selected item in dark mode - the light theme's #1e282c mixed 20% with black, with
   the dark header colour as its edge. Mirrors the "Selected item" block above. */
[data-bs-theme="dark"] .app-sidebar .sidebar-menu .nav-link.active,
[data-bs-theme="dark"] .app-sidebar .sidebar-menu > .nav-item > .nav-link.active,
[data-bs-theme="dark"] .app-sidebar .nav-treeview .nav-link.active,
[data-bs-theme="dark"] .app-sidebar .nav-treeview .nav-treeview .nav-link.active {
    color: #fff;
    background-color: #182023;
    border-inline-end: 3px solid #3d3727;
}

[data-bs-theme="dark"] .app-sidebar .nav-treeview .nav-treeview {
    background: #1b2f37;
}


/* --- Sidebar legibility ---------------------------------------------------
 * AdminLTE 4 renders sidebar links at #c2c7d0, which reads as washed-out grey
 * against the #406472 slate. The original AdminLTE 2 skin used #e7eef2, and the
 * icons inherited it. These selectors are specific enough to win against
 * AdminLTE's own .sidebar-menu rules in both themes.
 * ------------------------------------------------------------------------- */

.app-sidebar .sidebar-menu .nav-item > .nav-link,
.app-sidebar .sidebar-menu .nav-item > .nav-link .nav-icon,
.app-sidebar .sidebar-menu .nav-item > .nav-link p,
.app-sidebar .sidebar-wrapper .nav-link,
.app-sidebar .sidebar-wrapper .nav-link .nav-icon {
    color: #f2f6f8;
}

.app-sidebar .nav-treeview > .nav-item > .nav-link,
.app-sidebar .nav-treeview > .nav-item > .nav-link .nav-icon,
.app-sidebar .nav-treeview > .nav-item > .nav-link p {
    color: #eff4f6;
}

.app-sidebar .sidebar-menu .nav-item > .nav-link:hover,
.app-sidebar .sidebar-menu .nav-item > .nav-link:hover .nav-icon,
.app-sidebar .sidebar-menu .nav-item > .nav-link.active,
.app-sidebar .sidebar-menu .nav-item > .nav-link.active .nav-icon {
    color: #fff;
}

.app-sidebar .sidebar-brand .brand-text,
.app-sidebar .sidebar-brand .brand-link { color: #fff; }

/* Header text and icons sit on the gold bar in both themes. */
.app-header .nav-link,
.app-header .nav-link i,
.app-header .navbar-nav .nav-link,
.app-header .nav-item > span.nav-link,
.app-header .nav-item > span.nav-link b {
    color: #fff;
}

/* --- Native controls the app never gave a class ---------------------------
 * Plenty of inputs in settings/ and the report filters are bare <input> or
 * <textarea> elements. With color-scheme fixed they are light again, but they
 * still deserve to look like the rest of the form.
 * ------------------------------------------------------------------------- */

[data-bs-theme="light"] .app-main input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([class*="form-"]):not([class*="btn"]),
[data-bs-theme="light"] .app-main textarea:not([class*="form-"]),
[data-bs-theme="light"] .app-main select:not([class*="form-"]) {
    padding: 0.25rem 0.5rem;
    color: #333;
    background-color: #fff;
    border: 1px solid #d2d6de;
    border-radius: 0.25rem;
}

/* ---------------------------------------------------------------------------
 * Dark mode contrast
 *
 * Several components keep a light background of their own regardless of theme:
 * Bootstrap 3's soft .bg-success/.bg-info/.bg-warning/.bg-danger fills, the
 * .callout boxes, and the coloured panel headers on the invoice and settings
 * screens. In dark mode the surrounding text colour flips to #dee2e6 and those
 * blocks became light-on-light - the ZATCA sandbox notice in settings was the
 * clearest case. Text inside a known-light surface is pinned dark instead of
 * inheriting the theme.
 * ------------------------------------------------------------------------- */

[data-bs-theme="dark"] .bg-success,
[data-bs-theme="dark"] .bg-info,
[data-bs-theme="dark"] .bg-warning,
[data-bs-theme="dark"] .bg-danger,
[data-bs-theme="dark"] .bg-gray,
[data-bs-theme="dark"] .bg-success *,
[data-bs-theme="dark"] .bg-info *,
[data-bs-theme="dark"] .bg-warning *,
[data-bs-theme="dark"] .bg-danger *,
[data-bs-theme="dark"] .bg-gray * {
    color: #212529;
}

/* .alert-* is deliberately absent above. Bootstrap 5.3 restyles alerts for the dark
   theme - .alert-info comes out as dark teal - so pinning #212529 on them produced
   near-black text on a dark panel (the "unlimited number of users" notice was the
   clearest case). Left to Bootstrap, they are legible in both themes. */

/* Inline background colours set on elements in the markup (the invoice supplier /
 * client panels use pale yellows and blues) also need dark text. */
[data-bs-theme="dark"] [style*="background"] {
    color: #212529;
}

[data-bs-theme="dark"] [style*="background"] a { color: #0a58ca; }

/* ...but a solid AdminLTE colour fill keeps its white text. */
[data-bs-theme="dark"] .bg-blue, [data-bs-theme="dark"] .bg-blue *,
[data-bs-theme="dark"] .bg-navy, [data-bs-theme="dark"] .bg-navy *,
[data-bs-theme="dark"] .bg-green, [data-bs-theme="dark"] .bg-green *,
[data-bs-theme="dark"] .bg-red, [data-bs-theme="dark"] .bg-red *,
[data-bs-theme="dark"] .bg-aqua, [data-bs-theme="dark"] .bg-aqua *,
[data-bs-theme="dark"] .bg-orange, [data-bs-theme="dark"] .bg-orange *,
[data-bs-theme="dark"] .bg-yellow, [data-bs-theme="dark"] .bg-yellow *,
[data-bs-theme="dark"] .bg-purple, [data-bs-theme="dark"] .bg-purple *,
[data-bs-theme="dark"] .bg-maroon, [data-bs-theme="dark"] .bg-maroon *,
[data-bs-theme="dark"] .bg-primary, [data-bs-theme="dark"] .bg-primary *,
[data-bs-theme="dark"] .callout, [data-bs-theme="dark"] .callout * {
    color: #fff;
}

/* ...except a `.btn` nested inside one of those fills, which carries its own
   background and its own colour (Bootstrap's --bs-btn-color). The blanket rule
   above is right for the surrounding text and icons, which have no background
   of their own and would otherwise vanish into the fill - but .btn-default is a
   WHITE button, and forcing white text onto it is white-on-white. First hit by
   the "Get the app" button inside the mobile app banner's bg-navy strip; nothing
   put a .btn inside one of these fills before. Restored after the blanket rule
   so it wins on source order at equal specificity - both are two classes plus
   the attribute selector. */
[data-bs-theme="dark"] .bg-blue .btn, [data-bs-theme="dark"] .bg-blue .btn *,
[data-bs-theme="dark"] .bg-navy .btn, [data-bs-theme="dark"] .bg-navy .btn *,
[data-bs-theme="dark"] .bg-green .btn, [data-bs-theme="dark"] .bg-green .btn *,
[data-bs-theme="dark"] .bg-red .btn, [data-bs-theme="dark"] .bg-red .btn *,
[data-bs-theme="dark"] .bg-aqua .btn, [data-bs-theme="dark"] .bg-aqua .btn *,
[data-bs-theme="dark"] .bg-orange .btn, [data-bs-theme="dark"] .bg-orange .btn *,
[data-bs-theme="dark"] .bg-yellow .btn, [data-bs-theme="dark"] .bg-yellow .btn *,
[data-bs-theme="dark"] .bg-purple .btn, [data-bs-theme="dark"] .bg-purple .btn *,
[data-bs-theme="dark"] .bg-maroon .btn, [data-bs-theme="dark"] .bg-maroon .btn *,
[data-bs-theme="dark"] .bg-primary .btn, [data-bs-theme="dark"] .bg-primary .btn *,
[data-bs-theme="dark"] .callout .btn, [data-bs-theme="dark"] .callout .btn * {
    color: var(--bs-btn-color);
}

/* The theme switch itself */
.theme-toggle .fa-sun-o { display: none; }
[data-bs-theme="dark"] .theme-toggle .fa-sun-o { display: inline-block; }
[data-bs-theme="dark"] .theme-toggle .fa-moon-o { display: none; }

/* ---------------------------------------------------------------------------
 * Chart of Accounts tabs
 *
 * Folder-shaped like every other .nav-tabs strip in the app now (see "Tab
 * strips: make it obvious the tabs ARE tabs" further down: tinted strip,
 * bordered/filled inactive tabs, rounded top corners) instead of bare text
 * with a coloured bar above it - but kept centred (.centered, which is why
 * this strip cannot just join that shared :not(.centered) rule), and with
 * each tab's own colour restored as a solid fill on the *selected* tab, the
 * way this looked before the folder-tab shape existed, rather than the
 * shared rule's single shared #3c8dbc top-border accent.
 *
 * White-on-#f39c12 (the gold Owner's Equity fill) measures 2.2:1, well under
 * WCAG AA's 4.5:1 - carried over rather than fixed here, since it is exactly
 * what production already shows today and this task is to reshape the tabs,
 * not to re-litigate a contrast call already live everywhere else this
 * colour is used as a fill (e.g. the equity org-chart nodes below).
 * ------------------------------------------------------------------------- */

.nav-tabs.centered {
    justify-content: center;
    gap: 3px;
    padding: 6px 8px 0;
    background: #eef2f5;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

.nav-tabs.centered > .nav-item > .nav-link {
    min-width: 11rem;
    margin-bottom: -1px;
    padding: 0.45rem 1.25rem;
    text-align: center;
    line-height: 1.35;
    font-weight: 500;
    background-color: #e2e8ec;
    border: 1px solid #d6dde2;
    border-top: 3px solid transparent;
    border-radius: 4px 4px 0 0;
}

.nav-tabs.centered > .nav-item > .nav-link:hover,
.nav-tabs.centered > .nav-item > .nav-link:focus {
    background-color: #f4f7f9;
    border-top-color: #a9c4d4;
}

.nav-tabs.centered > .nav-item > .nav-link.coa-tab-asset       { border-top-color: #00a65a; }
.nav-tabs.centered > .nav-item > .nav-link.coa-tab-equity      { border-top-color: #f39c12; }
.nav-tabs.centered > .nav-item > .nav-link.coa-tab-liabilities { border-top-color: #dd4b39; }

/* The selected tab takes its colour as a solid fill, as production did. */
.nav-tabs.centered > .nav-item > .nav-link.active.coa-tab-asset       { background-color: #00a65a !important; border-color: #00a65a; }
.nav-tabs.centered > .nav-item > .nav-link.active.coa-tab-equity      { background-color: #f39c12 !important; border-color: #f39c12; }
.nav-tabs.centered > .nav-item > .nav-link.active.coa-tab-liabilities { background-color: #dd4b39 !important; border-color: #dd4b39; }

.nav-tabs.centered > .nav-item > .nav-link.active,
.nav-tabs.centered > .nav-item > .nav-link.active * {
    color: #fff !important;
    font-weight: 600;
}

.nav-tabs.centered > .nav-item > .nav-link:not(.active),
.nav-tabs.centered > .nav-item > .nav-link:not(.active) * {
    color: #40525e !important;
}

/* Dark mode - same surfaces as the shared :not(.centered) strip above
   (strip #1a1f24 < unselected #212830 < selected = its own panel), which is
   what that block's own comment explains at length. Only the strip and the
   unselected tabs need it: the selected tab keeps its solid brand-colour
   fill and white text in both themes, unchanged, and already reads fine on a
   dark page - it is a saturated colour block either way, not a surface that
   is supposed to sit at "page" or "card" darkness. Missing this dark variant
   is what left the strip's own background white in dark mode: it inherited
   nothing from the shared rule, because .centered opts out of it. */
[data-bs-theme="dark"] .nav-tabs.centered {
    background: #1a1f24;
    border-bottom-color: #39434a;
}

[data-bs-theme="dark"] .nav-tabs.centered > .nav-item > .nav-link {
    background-color: #212830;
    border-color: #39434a;
}

[data-bs-theme="dark"] .nav-tabs.centered > .nav-item > .nav-link:hover,
[data-bs-theme="dark"] .nav-tabs.centered > .nav-item > .nav-link:focus {
    background-color: #2c353d;
}

[data-bs-theme="dark"] .nav-tabs.centered > .nav-item > .nav-link:not(.active),
[data-bs-theme="dark"] .nav-tabs.centered > .nav-item > .nav-link:not(.active) * {
    color: #b7c6d0 !important;
}

/* ---------------------------------------------------------------------------
 * User menu panel
 *
 * A pass at AdminLTE 4's own sample structure (large circular avatar in
 * .user-header, Settings moved into .user-body, a two-button .user-footer)
 * was tried and reverted - back to the three actions in one compact footer
 * row this app had. AdminLTE 4's native .user-header still defaults to a
 * 175px min-height sized for that avatar this app does not have, so it is
 * pinned back down to fit the name/e-mail text only.
 *
 * What is new here: the panel is wider than either the old 20rem or AdminLTE
 * 4's native 280-300px (dropdown-menu-lg), so all three buttons sit larger
 * and less cramped than before rather than shrunk to fit. Buttons are
 * Bootstrap's own btn-outline-secondary (Profile, Settings) and
 * btn-outline-danger (Sign out) - outlined at rest, filling solid on hover,
 * which is Bootstrap's stock .btn-outline-* behaviour and needs no CSS here.
 * ------------------------------------------------------------------------- */

.navbar-nav .user-menu > .dropdown-menu {
    /* Sized to its content rather than to a round number. The footer below
       fixes all three of its gaps (12px inset, 12px to Settings, 37px to Sign
       Out), so the panel's width is whatever those plus the three button
       widths come to - which differs between English and Arabic. A fixed
       width would leave dead space after Sign Out in one locale or crowd it
       in the other; max-content lets the row decide, and the min/max keep it
       sane if a name or e-mail in the header above is unusually long.

       max-width also has to be re-stated because dropdown-menu-lg on the <ul>
       caps it at 300px - a different property to width, so it clamped this
       regardless of selector specificity, and the buttons overflowed past the
       visible edge of a menu measuring 300px. */
    width: max-content;
    min-width: 20rem;
    max-width: min(30rem, 92vw);
    padding: 0;
    overflow: hidden;
}

/* li.user-header, not .user-header: AdminLTE 4 ships this same 175px min-height
   twice, once as a plain .user-header rule and once as
   .navbar-nav > .user-menu > .dropdown-menu > li.user-header - the second
   has one more element in the selector than a class-only override does, which
   is worth as much specificity as a whole extra class, and it was winning
   despite loading first. Matching the compound selector ties specificity and
   lets load order (this file is last) decide instead. */
.navbar-nav .user-menu > .dropdown-menu > li.user-header {
    height: auto;
    min-height: 0;
    padding: 0.9rem 0.75rem;
    text-align: center;
}

.navbar-nav .user-menu > .dropdown-menu > li.user-header p {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.4;
}

.navbar-nav .user-menu > .dropdown-menu > li.user-header small {
    display: block;
    font-size: 0.8rem;
    opacity: 0.9;
}

/* Grouping, not even spacing: My Profile and Settings are both "go somewhere
   and change something", Sign Out ends the session. space-between spread all
   three evenly (37px between each), which said nothing about that split.
   They are packed from the start edge instead, one 12px gap apart - the same
   12px as the panel's own inset, so the pair reads as a block flush with the
   panel edge - and Sign Out keeps its original 37px via the extra margin
   below. Same gaps in RTL: gap and margin-inline-start are both
   direction-relative, and Sign Out is last in DOM order either way. */
.navbar-nav .user-menu > .dropdown-menu > .user-footer {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
}

/* 0.75rem gap + 1.5625rem = the 2.3125rem (37px) Sign Out had before. */
.navbar-nav .user-menu > .dropdown-menu > .user-footer .btn-outline-danger {
    margin-inline-start: 1.5625rem;
}

/* AdminLTE 4's own .user-footer::after is a clearfix left over from the
   original float-based layout (`clear:both`, meaningless once nothing here
   floats). In a flex container a `content:""` pseudo-element does not just
   sit there unused - it becomes a real, if invisible, fourth flex item. With
   3 buttons + that phantom item, space-between divided the row into 4 slots
   instead of 3, so Sign Out landed in slot 3 with a whole extra gap between
   it and the phantom in slot 4 - it was never actually the last item. That
   was the mismatched left/right edge distance. */
.navbar-nav .user-menu > .dropdown-menu > .user-footer::after {
    content: none;
}

.navbar-nav .user-menu > .dropdown-menu > .user-footer .btn {
    flex: 0 0 auto;
    float: none !important;
    /* .btn-flat (bs5-compat.css) pins border-radius to 0 everywhere it is
       used, which is correct for the flat panel buttons it was written for -
       overridden back to a real radius just for these three. */
    border-radius: var(--bs-border-radius-lg, 8px) !important;
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * Sidebar: AdminLTE 4 typography, highlighting and caret direction
 * ------------------------------------------------------------------------- */

/* Closed carets point toward the content in RTL; the open state keeps AdminLTE's
   +90deg rotation, which reads as "down" from either starting direction. */
[dir="rtl"] .app-sidebar .nav-arrow {
    transform: translateY(-50%) rotate(180deg);
}

[dir="rtl"] .app-sidebar .nav-item.menu-open > .nav-link .nav-arrow {
    transform: translateY(-50%) rotate(90deg);
}

/* AdminLTE 4 sizing/spacing for sidebar links. */
.app-sidebar .sidebar-menu .nav-link {
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.1px;
}

.app-sidebar .sidebar-menu .nav-link .nav-icon {
    width: 1.6rem;
    margin-inline-end: 0.35rem;
    font-size: 1rem;
    text-align: center;
}

.app-sidebar .nav-treeview > .nav-item > .nav-link {
    padding-inline-start: 2.4rem;
    font-size: 0.9rem;
}

.app-sidebar .nav-treeview .nav-treeview > .nav-item > .nav-link {
    padding-inline-start: 3.4rem;
}

/* Selected item: a solid block with an accent edge, as the gold skin had. */
.app-sidebar .sidebar-menu .nav-link.active,
.app-sidebar .sidebar-menu .nav-link.active .nav-icon,
.app-sidebar .sidebar-menu .nav-link.active p {
    font-weight: 600;
}

.app-sidebar .nav-header {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

/* ---------------------------------------------------------------------------
 * Page content spacing and header typography
 *
 * AdminLTE 2 gave the content area 15px of padding and styled the page title
 * block explicitly. AdminLTE 4 dropped both, so content sat flush against the top
 * bar and a page title like
 *
 *     <h1>Business Intelligence <small>Analyze your business data over time</small></h1>
 *
 * rendered as one large bold line instead of a 24px heading with a light 15px
 * subtitle. Values below are the AdminLTE 2 originals:
 *   .content-header      padding: 15px 15px 0
 *   .content-header > h1 margin: 0; font-size: 24px
 *   .content-header small font-size: 15px; font-weight: 300
 * ------------------------------------------------------------------------- */

.app-main > .app-content,
.app-main > .app-content-header {
    padding-top: 15px;
}

.app-main > .app-content > .container-fluid {
    padding-right: 15px;
    padding-left: 15px;
}

.content-header {
    position: relative;
    padding: 15px 15px 0;
}

.content-header > h1,
.content-header > h2,
.content-header > h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 500;
}

/* The subtitle in a page heading: smaller, lighter, muted - in any heading level,
   so every screen using this pattern matches without per-page rules. */
.content-header h1 > small,
.content-header h2 > small,
.content-header h3 > small,
.app-main h1 > small,
.app-main h2 > small,
.app-main h3 > small,
.app-main h4 > small {
    display: inline-block;
    padding-inline-start: 4px;
    font-size: 15px;
    font-weight: 300;
    color: #777;
}

[data-bs-theme="dark"] .content-header h1 > small,
[data-bs-theme="dark"] .app-main h1 > small,
[data-bs-theme="dark"] .app-main h2 > small,
[data-bs-theme="dark"] .app-main h3 > small,
[data-bs-theme="dark"] .app-main h4 > small {
    color: #adb5bd;
}

/* Bootstrap 5 paints table cell backgrounds from --bs-table-bg on each th/td, which
   beats a bg-* class set on the <thead>. The invoice line-item tables rely on
   <thead class="bg-navy">, so the colour is re-applied at cell level. */
.table > thead.bg-navy > tr > th,
.table > thead.bg-blue > tr > th,
.table > thead.bg-green > tr > th,
.table > thead.bg-gray > tr > th {
    color: #fff;
    background-color: inherit;
    --bs-table-bg: transparent;
    --bs-table-color: #fff;
}

.table > thead.bg-navy  { background-color: #001f3f !important; }
.table > thead.bg-blue  { background-color: #0073b7 !important; }
.table > thead.bg-green { background-color: #00a65a !important; }
.table > thead.bg-gray  { background-color: #d2d6de !important; }
.table > thead.bg-gray > tr > th { color: #333; --bs-table-color: #333; }

/* ---------------------------------------------------------------------------
 * Heading scale
 *
 * Bootstrap 5 enlarged every heading (h1 40px, h2 32px, h3 28px, h4 24px). This
 * app's layouts were built against Bootstrap 3's smaller scale, so section titles
 * like "Amount Due (SAR)", "Payment" and "Supplier" came out oversized. The
 * Bootstrap 3 values are restored for content headings, application-wide, rather
 * than per page.
 * ------------------------------------------------------------------------- */

.app-main h1, .app-main .h1 { font-size: 36px; }
.app-main h2, .app-main .h2 { font-size: 30px; }
.app-main h3, .app-main .h3 { font-size: 24px; }
.app-main h4, .app-main .h4 { font-size: 18px; }
.app-main h5, .app-main .h5 { font-size: 14px; }
.app-main h6, .app-main .h6 { font-size: 12px; }

/* The page-title block keeps its own 24px size (set above with .content-header). */

/* ---------------------------------------------------------------------------
 * Coloured table rows
 *
 * Bootstrap 5 paints a background on every th/td from --bs-table-bg, which sits on
 * top of any colour set on the <tr>. The invoice totals use <tr class="bg-success">
 * and <tr class="bg-danger">, so those rows lost their green / pink banding and
 * rendered plain white. Bootstrap 3's contextual row classes (.success, .danger,
 * .warning, .info, .active) are covered too, with the original BS3 colours.
 * ------------------------------------------------------------------------- */

.table > tbody > tr.bg-success > td, .table > tbody > tr.bg-success > th,
.table > tbody > tr.success > td,    .table > tbody > tr.success > th,
.table > tr.bg-success > td,         .table > tr.success > td {
    --bs-table-bg: transparent;
    --bs-table-color: #212529;
    color: #212529;
    background-color: #dff0d8 !important;
}

.table > tbody > tr.bg-danger > td, .table > tbody > tr.bg-danger > th,
.table > tbody > tr.danger > td,    .table > tbody > tr.danger > th,
.table > tr.bg-danger > td,         .table > tr.danger > td {
    --bs-table-bg: transparent;
    --bs-table-color: #212529;
    color: #212529;
    background-color: #f2dede !important;
}

.table > tbody > tr.bg-warning > td, .table > tbody > tr.warning > td,
.table > tr.bg-warning > td,         .table > tr.warning > td {
    --bs-table-bg: transparent;
    --bs-table-color: #212529;
    color: #212529;
    background-color: #fcf8e3 !important;
}

.table > tbody > tr.bg-info > td, .table > tbody > tr.info > td,
.table > tr.bg-info > td,         .table > tr.info > td {
    --bs-table-bg: transparent;
    --bs-table-color: #212529;
    color: #212529;
    background-color: #d9edf7 !important;
}

.table > tbody > tr.active > td, .table > tr.active > td {
    --bs-table-bg: transparent;
    background-color: #f5f5f5 !important;
}

/* ---------------------------------------------------------------------------
 * Settings: values the system owns, shown as text rather than as a field
 *
 * The ZATCA device UUID and environment are generated/switched by the app, never
 * typed. They used to be readonly <input>s, which still look like something you can
 * click into and edit - a grey box reads as "disabled for now", not "this is not a
 * control". Bootstrap's .form-control-plaintext keeps them on the same baseline as
 * the real fields in the column so the form still lines up; the weight separates the
 * value from the help text under it, and break-all stops the 36-character UUID from
 * pushing the column wide.
 * ------------------------------------------------------------------------- */
.settings-static-value {
    font-weight: 500;
    word-break: break-all;
}

/* ---------------------------------------------------------------------------
 * Expiring / expired items: softer column headings
 *
 * These headers inherited the browser's default `th { font-weight: bold }` on top of
 * a pinned full-contrast colour - pure black in light mode, pure white in dark - so
 * the four short labels read heavier than the data underneath them, which is the part
 * worth looking at. 500 and a mid grey keeps the header/body distinction without the
 * headings shouting - measured at 4.7:1 in light and 5.2:1 in dark, so both still
 * clear AA against their card. A step further would drop the dark one under 4:1.
 *
 * The same three ids are used by the dashboard's Expiring Items card and by the
 * Business Intelligence page, so this one block covers both. That is also the trap:
 * changing it here changes both, which is what is wanted, but check the BI page too
 * if these selectors are ever narrowed.
 * ------------------------------------------------------------------------- */
#expiringProductsTable > thead > tr > th,
#expiringMaterialsTable > thead > tr > th,
#expiredItemsTable > thead > tr > th {
    color: #6c757d;
    font-weight: 500;
}

[data-bs-theme="dark"] #expiringProductsTable > thead > tr > th,
[data-bs-theme="dark"] #expiringMaterialsTable > thead > tr > th,
[data-bs-theme="dark"] #expiredItemsTable > thead > tr > th {
    color: #9aa2aa;
}

/* The same overpainting hides a colour set on <thead> itself, which the views use 26x
 * bg-navy, 20x bg-info and 14x bg-gray. Those header bands were plain white in light
 * mode, and in dark mode the header text was invisible: the dark-surface rule further
 * up pins #212529 on .bg-info/.bg-gray because they are light surfaces, but with the
 * fill painted over, that was #212529 text on a #212529 cell. Colours match the <tr>
 * rules above so a header band and a banded row agree.
 * ------------------------------------------------------------------------- */

.table > thead.bg-info > tr > th,  .table > thead > tr.bg-info > th,
.table > thead.bg-info > tr > td,  .table > thead > tr.bg-info > td {
    --bs-table-bg: transparent;
    --bs-table-color: #212529;
    color: #212529;
    background-color: #d9edf7 !important;
}

.table > thead.bg-gray > tr > th,  .table > thead > tr.bg-gray > th,
.table > thead.bg-gray > tr > td,  .table > thead > tr.bg-gray > td {
    --bs-table-bg: transparent;
    --bs-table-color: #212529;
    color: #212529;
    background-color: #d2d6de !important;
}

.table > thead.bg-navy > tr > th,  .table > thead > tr.bg-navy > th,
.table > thead.bg-navy > tr > td,  .table > thead > tr.bg-navy > td {
    --bs-table-bg: transparent;
    --bs-table-color: #fff;
    color: #fff;
    background-color: #001f3f !important;
}

/* A <tr> carrying a solid AdminLTE fill keeps white text at cell level too. */
.table > tbody > tr.bg-navy > td, .table > tbody > tr.bg-blue > td,
.table > tbody > tr.bg-green > td, .table > tbody > tr.bg-red > td {
    --bs-table-bg: transparent;
    --bs-table-color: #fff;
    color: #fff;
    background-color: inherit;
}

/* ---------------------------------------------------------------------------
 * Solid AdminLTE fills on table cells
 *
 * Bootstrap 5 paints every th/td from --bs-table-bg and --bs-table-color, which
 * covers a bg-* class set on the cell or its row and leaves the text at the table's
 * inherited colour. On the ledger totals row - <td class="bg-black strong"> - that
 * produced a black cell with near-black text: completely unreadable.
 *
 * Each solid fill is therefore restated at cell level together with its foreground,
 * for both <td>/<th> and <tr>. Counts in the views: bg-gray 69, bg-black 35,
 * bg-navy 26, bg-gray-light 5, bg-maroon 1.
 * ------------------------------------------------------------------------- */

.table > tbody > tr > td.bg-black,   .table > tbody > tr > th.bg-black,
.table > tbody > tr.bg-black > td,   .table > tfoot > tr > td.bg-black,
/* ...and the header cells of a row carrying the colour - a totals row is usually written
   as <tr class="bg-black"><th>, which the td-only arm above does not reach. */
.table > tbody > tr.bg-black > th,   .table > tfoot > tr.bg-black > th,
.table > thead > tr > th.bg-black,   table > tbody > tr > td.bg-black {
    --bs-table-bg: transparent;
    --bs-table-color: #fff;
    color: #fff !important;
    background-color: #111 !important;
}

.table > tbody > tr > td.bg-navy,  .table > tbody > tr > th.bg-navy,
.table > thead > tr > th.bg-navy,  table > tbody > tr > td.bg-navy {
    --bs-table-bg: transparent; --bs-table-color: #fff;
    color: #fff !important; background-color: #001f3f !important;
}

.table > tbody > tr > td.bg-blue,   .table > thead > tr > th.bg-blue,
table > tbody > tr > td.bg-blue {
    --bs-table-bg: transparent; --bs-table-color: #fff;
    color: #fff !important; background-color: #0073b7 !important;
}

.table > tbody > tr > td.bg-green,  .table > thead > tr > th.bg-green,
table > tbody > tr > td.bg-green {
    --bs-table-bg: transparent; --bs-table-color: #fff;
    color: #fff !important; background-color: #00a65a !important;
}

.table > tbody > tr > td.bg-red,    .table > thead > tr > th.bg-red,
table > tbody > tr > td.bg-red {
    --bs-table-bg: transparent; --bs-table-color: #fff;
    color: #fff !important; background-color: #dd4b39 !important;
}

.table > tbody > tr > td.bg-maroon, .table > thead > tr > th.bg-maroon {
    --bs-table-bg: transparent; --bs-table-color: #fff;
    color: #fff !important; background-color: #d81b60 !important;
}

.table > tbody > tr > td.bg-aqua,   .table > thead > tr > th.bg-aqua {
    --bs-table-bg: transparent; --bs-table-color: #fff;
    color: #fff !important; background-color: #00c0ef !important;
}

.table > tbody > tr > td.bg-orange, .table > thead > tr > th.bg-orange,
.table > tbody > tr > td.bg-yellow, .table > thead > tr > th.bg-yellow {
    --bs-table-bg: transparent; --bs-table-color: #fff;
    color: #fff !important; background-color: #f39c12 !important;
}

.table > tbody > tr > td.bg-purple, .table > thead > tr > th.bg-purple {
    --bs-table-bg: transparent; --bs-table-color: #fff;
    color: #fff !important; background-color: #605ca8 !important;
}

/* Light fills keep dark text.

   NOTE the `tr.bg-gray > th` arm. A section heading is commonly written as a whole row of
   header cells - <tr class="bg-gray"><th colspan="3"> - and covering only `tr.bg-gray > td`
   left those cells with no fill at all: readable by luck in light mode, and #212529 on
   #212529 in dark mode, i.e. a heading nobody could see. Same trap as the tfoot <th> noted
   in CLAUDE.md, so cover BOTH cell types wherever a colour is carried on the row. */
.table > tbody > tr > td.bg-gray,   .table > tbody > tr > th.bg-gray,
.table > thead > tr > th.bg-gray,   .table > tbody > tr.bg-gray > td,
.table > tbody > tr.bg-gray > th,
table > tbody > tr > td.bg-gray {
    --bs-table-bg: transparent; --bs-table-color: #000;
    color: #000 !important; background-color: #d2d6de !important;
}

.table > tbody > tr > td.bg-gray-light, .table > thead > tr > th.bg-gray-light,
table > tbody > tr > td.bg-gray-light {
    --bs-table-bg: transparent; --bs-table-color: #212529;
    color: #212529 !important; background-color: #f7f7f7 !important;
}

/* Same treatment outside tables, where BS5 does not repaint but the AdminLTE
   foreground still needs to come along. */
.bg-black, .bg-black * { color: #fff; }
.bg-black { background-color: #111 !important; }
.bg-gray-light { background-color: #f7f7f7 !important; }

/* ---------------------------------------------------------------------------
 * Legacy bgcolor="" attributes on report tables
 *
 * The VAT return and general sales/purchases reports colour their sections with the
 * old presentational attribute - <tr bgcolor='#eeffe6'>, <td bgcolor='#e6e6e6'> -
 * rather than classes. A bgcolor attribute maps to an author-origin style with the
 * LOWEST priority, so Bootstrap 5's `.table > :not(caption) > * > * {
 * background-color: var(--bs-table-bg) }` paints straight over it and every section
 * came out plain white: the green "VAT ON SALES" band, the amber "VAT ON PURCHASES"
 * band, the lavender totals block and the grey not-applicable cells all vanished.
 *
 * CSS cannot read an attribute's value, so each colour actually used is matched
 * explicitly. Cells inside a coloured ROW are made transparent instead, so the row
 * colour shows through. 33 occurrences across 5 report views.
 * ------------------------------------------------------------------------- */

/* In dark mode the surrounding text flips to a light colour, but these bands keep
 * their pale bgcolor fills - so the VAT return's "VAT ON SALES" / "VAT ON PURCHASES"
 * headings and the sales/purchase report column headers were white on pale green,
 * amber and lavender. Text sitting on a bgcolor fill is pinned dark, exactly as the
 * class-based fills above are. The descendant selector covers the <center>, <strong>
 * and <font> wrappers the report markup uses inside those cells. */
[data-bs-theme="dark"] .table > thead > tr[bgcolor] > th,
[data-bs-theme="dark"] .table > thead > tr[bgcolor] > td,
[data-bs-theme="dark"] .table > tbody > tr[bgcolor] > th,
[data-bs-theme="dark"] .table > tbody > tr[bgcolor] > td,
[data-bs-theme="dark"] .table > thead > tr > th[bgcolor],
[data-bs-theme="dark"] .table > thead > tr > td[bgcolor],
[data-bs-theme="dark"] .table > tbody > tr > th[bgcolor],
[data-bs-theme="dark"] .table > tbody > tr > td[bgcolor],
[data-bs-theme="dark"] .table > thead > tr[bgcolor] > th *,
[data-bs-theme="dark"] .table > thead > tr[bgcolor] > td *,
[data-bs-theme="dark"] .table > tbody > tr[bgcolor] > th *,
[data-bs-theme="dark"] .table > tbody > tr[bgcolor] > td *,
[data-bs-theme="dark"] .table > thead > tr > th[bgcolor] *,
[data-bs-theme="dark"] .table > thead > tr > td[bgcolor] *,
[data-bs-theme="dark"] .table > tbody > tr > th[bgcolor] *,
[data-bs-theme="dark"] .table > tbody > tr > td[bgcolor] *,
[data-bs-theme="dark"] .table > tbody[bgcolor] > tr > th,
[data-bs-theme="dark"] .table > tbody[bgcolor] > tr > td,
[data-bs-theme="dark"] .table > thead[bgcolor] > tr > th,
[data-bs-theme="dark"] .table > thead[bgcolor] > tr > td,
[data-bs-theme="dark"] .table > tbody[bgcolor] > tr > th *,
[data-bs-theme="dark"] .table > tbody[bgcolor] > tr > td *,
[data-bs-theme="dark"] .table > thead[bgcolor] > tr > th *,
[data-bs-theme="dark"] .table > thead[bgcolor] > tr > td * {
    color: #212529;
}

/* The attribute also appears on <tbody> itself - the VAT return's totals block
 * (#E7EAFA) and one pink band (#ffe6e6) - which no rule reached, so those two bands
 * were plain white in light mode and invisible-blue in dark. Painting the cells is
 * what makes an attribute on the section actually show. */
.table > tbody[bgcolor="#E7EAFA"] > tr > th,
.table > tbody[bgcolor="#E7EAFA"] > tr > td,
.table > thead[bgcolor="#E7EAFA"] > tr > th,
.table > thead[bgcolor="#E7EAFA"] > tr > td {
    --bs-table-bg: transparent;
    background-color: #E7EAFA !important;
}

.table > tbody[bgcolor="#ffe6e6"] > tr > th,
.table > tbody[bgcolor="#ffe6e6"] > tr > td,
.table > thead[bgcolor="#ffe6e6"] > tr > th,
.table > thead[bgcolor="#ffe6e6"] > tr > td {
    --bs-table-bg: transparent;
    background-color: #ffe6e6 !important;
}

/* Cells inside a coloured row: let the row's colour through. */
.table > thead > tr[bgcolor] > th,
.table > thead > tr[bgcolor] > td,
.table > tbody > tr[bgcolor] > th,
.table > tbody > tr[bgcolor] > td {
    --bs-table-bg: transparent;
    background-color: transparent !important;
}

/* #E7EAFA */
.table > thead > tr > th[bgcolor="#E7EAFA"],
.table > thead > tr > td[bgcolor="#E7EAFA"],
.table > tbody > tr > th[bgcolor="#E7EAFA"],
.table > tbody > tr > td[bgcolor="#E7EAFA"] {
    --bs-table-bg: transparent;
    background-color: #E7EAFA !important;
}
/* #c2c6e6 */
.table > thead > tr > th[bgcolor="#c2c6e6"],
.table > thead > tr > td[bgcolor="#c2c6e6"],
.table > tbody > tr > th[bgcolor="#c2c6e6"],
.table > tbody > tr > td[bgcolor="#c2c6e6"] {
    --bs-table-bg: transparent;
    background-color: #c2c6e6 !important;
}
/* #e6e6e6 */
.table > thead > tr > th[bgcolor="#e6e6e6"],
.table > thead > tr > td[bgcolor="#e6e6e6"],
.table > tbody > tr > th[bgcolor="#e6e6e6"],
.table > tbody > tr > td[bgcolor="#e6e6e6"] {
    --bs-table-bg: transparent;
    background-color: #e6e6e6 !important;
}
/* #eeffe6 */
.table > thead > tr > th[bgcolor="#eeffe6"],
.table > thead > tr > td[bgcolor="#eeffe6"],
.table > tbody > tr > th[bgcolor="#eeffe6"],
.table > tbody > tr > td[bgcolor="#eeffe6"] {
    --bs-table-bg: transparent;
    background-color: #eeffe6 !important;
}
/* #ffe6e6 */
.table > thead > tr > th[bgcolor="#ffe6e6"],
.table > thead > tr > td[bgcolor="#ffe6e6"],
.table > tbody > tr > th[bgcolor="#ffe6e6"],
.table > tbody > tr > td[bgcolor="#ffe6e6"] {
    --bs-table-bg: transparent;
    background-color: #ffe6e6 !important;
}
/* #fff7e6 */
.table > thead > tr > th[bgcolor="#fff7e6"],
.table > thead > tr > td[bgcolor="#fff7e6"],
.table > tbody > tr > th[bgcolor="#fff7e6"],
.table > tbody > tr > td[bgcolor="#fff7e6"] {
    --bs-table-bg: transparent;
    background-color: #fff7e6 !important;
}

/* ---------------------------------------------------------------------------
   .modal-wide - opt-in wider dialog

   Bootstrap 5's default .modal-dialog is 500px, which squeezes this app's
   two-column record forms into a narrow strip. Rather than widen every modal in
   the app, dialogs that need the room carry .modal-wide in their own markup, so
   what is affected is visible at each call site and greppable:

       grep -rn "modal-dialog modal-wide" resources/views/

   Applied to the client, supplier, product, material and asset add / edit / view
   dialogs. Confirmations and single-message dialogs keep Bootstrap's 500px.

   Only takes effect from 576px up, which is where Bootstrap constrains dialog
   width at all; below that the dialog stays full-width minus its margins.
   --------------------------------------------------------------------------- */
@media (min-width: 576px) {
    .modal-dialog.modal-wide {
        max-width: 1000px;
    }
}

/* ---------------------------------------------------------------------------
   .modal-document - the document viewer dialog

   A relative width rather than a pixel one, unlike .modal-wide above. This
   dialog holds an A4 page rendered as a PDF in an iframe, so what matters is how
   much of the SCREEN it gets: at .modal-wide's 1000px the page was letterboxed
   with grey on a wide monitor, and readable only by zooming inside the frame.
   80vw fills the display without going edge to edge, which would lose the sense
   of it being a dialog over the report.

   Used by layouts/partials/reference_modals - the invoice and credit note
   preview opened from a report.

   Same 576px floor as .modal-wide: below that Bootstrap does not constrain
   dialog width at all, and 80vw would make it NARROWER than the default
   full-width-minus-margins on a phone.
   --------------------------------------------------------------------------- */
@media (min-width: 576px) {
    .modal-dialog.modal-document {
        max-width: 80vw;
    }
}

/* ---------------------------------------------------------------------------
 * Colour classes on individual cells
 *
 * Same cause as the coloured rows above - Bootstrap paints every th/td from
 * --bs-table-bg, over anything the cell itself sets - but applied to the classes the
 * markup puts directly on a <td>/<th>: bg-info 104x, bg-gray 66, bg-primary 46,
 * bg-black 36, bg-navy 26, bg-danger 4, bg-maroon 1.
 *
 * Two consequences were visible. A `<td class="bg-primary">` on the roles screen kept
 * its near-white text but lost its blue fill, so "User Management" was white on white.
 * And `<tfoot><th class="bg-black">` in the VAT reports - the Total cell - was black on
 * #111, which is the same complaint as the ledger's "Total & Ending Balance" row.
 *
 * The earlier block only reached `tfoot > tr > td`, and the report markup writes a bare
 * <th> inside <tfoot> (the parser supplies the <tr>), so the Total cell fell through.
 * These selectors cover td and th in all three sections.
 * ------------------------------------------------------------------------- */

.table > thead > tr > th.bg-info,
.table > thead > tr > td.bg-info,
.table > tbody > tr > th.bg-info,
.table > tbody > tr > td.bg-info,
.table > tfoot > tr > th.bg-info,
.table > tfoot > tr > td.bg-info {
    --bs-table-bg: transparent;
    --bs-table-color: #212529;
    color: #212529 !important;
    background-color: #d9edf7 !important;
}

.table > thead > tr > th.bg-danger,
.table > thead > tr > td.bg-danger,
.table > tbody > tr > th.bg-danger,
.table > tbody > tr > td.bg-danger,
.table > tfoot > tr > th.bg-danger,
.table > tfoot > tr > td.bg-danger {
    --bs-table-bg: transparent;
    --bs-table-color: #212529;
    color: #212529 !important;
    background-color: #f2dede !important;
}

.table > thead > tr > th.bg-primary,
.table > thead > tr > td.bg-primary,
.table > tbody > tr > th.bg-primary,
.table > tbody > tr > td.bg-primary,
.table > tfoot > tr > th.bg-primary,
.table > tfoot > tr > td.bg-primary {
    --bs-table-bg: transparent;
    --bs-table-color: #fff;
    color: #fff !important;
    background-color: #337ab7 !important;
}

.table > thead > tr > th.bg-black,
.table > thead > tr > td.bg-black,
.table > tbody > tr > th.bg-black,
.table > tbody > tr > td.bg-black,
.table > tfoot > tr > th.bg-black,
.table > tfoot > tr > td.bg-black {
    --bs-table-bg: transparent;
    --bs-table-color: #fff;
    color: #fff !important;
    background-color: #111111 !important;
}

.table > thead > tr > th.bg-navy,
.table > thead > tr > td.bg-navy,
.table > tbody > tr > th.bg-navy,
.table > tbody > tr > td.bg-navy,
.table > tfoot > tr > th.bg-navy,
.table > tfoot > tr > td.bg-navy {
    --bs-table-bg: transparent;
    --bs-table-color: #fff;
    color: #fff !important;
    background-color: #001f3f !important;
}

.table > thead > tr > th.bg-gray,
.table > thead > tr > td.bg-gray,
.table > tbody > tr > th.bg-gray,
.table > tbody > tr > td.bg-gray,
.table > tfoot > tr > th.bg-gray,
.table > tfoot > tr > td.bg-gray {
    --bs-table-bg: transparent;
    --bs-table-color: #212529;
    color: #212529 !important;
    background-color: #d2d6de !important;
}

.table > thead > tr > th.bg-maroon,
.table > thead > tr > td.bg-maroon,
.table > tbody > tr > th.bg-maroon,
.table > tbody > tr > td.bg-maroon,
.table > tfoot > tr > th.bg-maroon,
.table > tfoot > tr > td.bg-maroon {
    --bs-table-bg: transparent;
    --bs-table-color: #fff;
    color: #fff !important;
    background-color: #d81b60 !important;
}

.table > thead > tr > th.bg-info *,
.table > thead > tr > td.bg-info *,
.table > tbody > tr > th.bg-info *,
.table > tbody > tr > td.bg-info *,
.table > tfoot > tr > th.bg-info *,
.table > tfoot > tr > td.bg-info * {
    color: #212529 !important;
}

.table > thead > tr > th.bg-danger *,
.table > thead > tr > td.bg-danger *,
.table > tbody > tr > th.bg-danger *,
.table > tbody > tr > td.bg-danger *,
.table > tfoot > tr > th.bg-danger *,
.table > tfoot > tr > td.bg-danger * {
    color: #212529 !important;
}

.table > thead > tr > th.bg-primary *,
.table > thead > tr > td.bg-primary *,
.table > tbody > tr > th.bg-primary *,
.table > tbody > tr > td.bg-primary *,
.table > tfoot > tr > th.bg-primary *,
.table > tfoot > tr > td.bg-primary * {
    color: #fff !important;
}

.table > thead > tr > th.bg-black *,
.table > thead > tr > td.bg-black *,
.table > tbody > tr > th.bg-black *,
.table > tbody > tr > td.bg-black *,
.table > tfoot > tr > th.bg-black *,
.table > tfoot > tr > td.bg-black * {
    color: #fff !important;
}

.table > thead > tr > th.bg-navy *,
.table > thead > tr > td.bg-navy *,
.table > tbody > tr > th.bg-navy *,
.table > tbody > tr > td.bg-navy *,
.table > tfoot > tr > th.bg-navy *,
.table > tfoot > tr > td.bg-navy * {
    color: #fff !important;
}

.table > thead > tr > th.bg-gray *,
.table > thead > tr > td.bg-gray *,
.table > tbody > tr > th.bg-gray *,
.table > tbody > tr > td.bg-gray *,
.table > tfoot > tr > th.bg-gray *,
.table > tfoot > tr > td.bg-gray * {
    color: #212529 !important;
}

.table > thead > tr > th.bg-maroon *,
.table > thead > tr > td.bg-maroon *,
.table > tbody > tr > th.bg-maroon *,
.table > tbody > tr > td.bg-maroon *,
.table > tfoot > tr > th.bg-maroon *,
.table > tfoot > tr > td.bg-maroon * {
    color: #fff !important;
}


/* ---------------------------------------------------------------------------
 * Settings > Theming and Colours
 *
 * Chrome for the theme picker itself: the preset cards and the little preview of
 * the shell. Deliberately theme-neutral - it must stay legible whatever colours
 * the user is trying out, and it renders in both light and dark mode.
 * ------------------------------------------------------------------------- */

.theme-card {
    border: 2px solid var(--bs-border-color, #d2d6de);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    height: 100%;
}

.theme-card:hover { border-color: #3c8dbc; }

.theme-card.selected {
    border-color: #3c8dbc;
    box-shadow: 0 0 0 3px rgba(60, 141, 188, 0.25);
}

/* Two-tone swatch: the rail on the left, the top bar across the rest. */
.theme-card-swatch { display: flex; height: 46px; }
.theme-swatch-side { width: 30%; }
.theme-swatch-top  { width: 70%; }

.theme-card-body { padding: 8px 10px; }

/* "In use" only shows on the selected card. */
.theme-badge {
    display: none;
    float: right;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #3c8dbc;
    color: #fff;
}

html[dir="rtl"] .theme-badge { float: left; }
.theme-card.selected .theme-badge { display: inline-block; }

/* Miniature of the application shell. */
.theme-preview {
    border: 1px solid var(--bs-border-color, #d2d6de);
    border-radius: 4px;
    overflow: hidden;
    width: 100%;
    max-width: 260px;
}

.theme-preview-top { display: flex; height: 26px; }
.theme-preview-brand {
    width: 34%;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-preview-bar { width: 66%; }

.theme-preview-body { display: flex; height: 92px; }
.theme-preview-side { width: 34%; padding-top: 4px; }
.theme-preview-content { width: 66%; background: #ecf0f5; }

[data-bs-theme="dark"] .theme-preview-content { background: #1b1f22; }

.theme-preview-navheader { display: block; height: 12px; }
.theme-preview-item {
    display: block;
    height: 9px;
    margin: 6px 8px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.35);
}
.theme-preview-sub { margin-inline-start: 16px; }


/* --- Sidebar icon colours -------------------------------------------------
 * The menu icons used to inherit the link colour, so the whole rail was one
 * flat near-white column and the icons carried no information beyond their
 * shape. They are coloured here instead, keyed off the Font Awesome class
 * itself - every menu entry already carries a distinct, meaningful icon (see
 * layouts/partials/left_sidebar.blade.php), so no extra markup is needed and a
 * new entry picks up a colour simply by reusing an existing icon.
 *
 * Three rules the palette follows, worth keeping:
 *   1. No two ADJACENT top-level entries share a hue - that is what makes the
 *      column scannable. Repeats are fine when they are far apart (amber is on
 *      Dashboard and Accounts, twelve rows apart).
 *   2. A repeated concept always keeps its colour. Sales is green and
 *      Purchases coral everywhere they appear (four subtrees each), which is
 *      what lets you read the pairs without reading the labels.
 *   3. Purely structural entries - List and Templates, eleven of them - stay a
 *      muted slate grey. Colouring those too turned the tree into confetti and
 *      drowned out the sections that matter.
 *
 * All nine theme presets ship a dark sidebar (#406472 down to #14424c), and
 * dark mode mixes each with 60% black, so one set of values reads correctly
 * throughout - there is no light-sidebar case to write a second palette for.
 *
 * Specificity: the legibility block above pins .nav-icon to #f2f6f8, and to
 * #fff on hover/active, at (0,6,0). The attribute selector here takes these to
 * (0,7,0), which is what keeps the colour through hover and on the active row
 * as well. ThemeHelper::cssOverrides() colours .nav-link rather than .nav-icon,
 * so a themed installation does not disturb these.
 * ------------------------------------------------------------------------- */

/* amber */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-dashboard,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-key,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-question-circle,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-book {
    color: #f5b342;
}

/* green - and "money in" wherever Sales appears */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-line-chart,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-sticky-note-o,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-money,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-upload {
    color: #4cd07d;
}

/* coral - "money out" wherever Purchases appears */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-shopping-cart {
    color: #ff8f6b;
}

/* sky */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-user-circle-o,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-user,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-file-text-o {
    color: #56b8f0;
}

/* indigo */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-users,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-sitemap {
    color: #8f9cff;
}

/* teal */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-address-book-o,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-exchange,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-balance-scale,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-tag {
    color: #3fd0c9;
}

/* orange */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-truck,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-download {
    color: #ff9a52;
}

/* lime */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-cubes,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-cube {
    color: #b7e05a;
}

/* violet */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-file-code-o,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-pie-chart {
    color: #b58bff;
}

/* pink */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-building-o,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-files-o,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-building,
/* Proforma invoices and quotes: paper documents, so they take the same hue as the
   other document entries. They sit under E-Invoices (violet) and well away from
   Import/Export, so the repeat does not land next to itself. */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-file-o,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-tags {
    color: #ff8fb1;
}

/* red */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-user-secret {
    color: #ff7a6b;
}

/* Structural entries stay quiet so the coloured sections keep their weight. */
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-list,
.app-sidebar[data-bs-theme] .sidebar-menu .nav-item .nav-link .nav-icon.fa-clone {
    /* Was #9fb3bd, which measured 1.92:1 against the submenu (#4d8399) while the
       label beside it sits at 3.77:1 - the icon read as disabled rather than as
       deliberately quiet. Lifted to roughly the label's own brightness, so these stay
       neutral against the coloured entries without looking switched off. The
       distinction here is meant to be hue, not dimness. */
    color: #d3e2e9;
}


/* --- Tab strips: make it obvious the tabs ARE tabs -------------------------
 * Users were not realising the Business Intelligence page had three views.
 * The cause was that Bootstrap 5 gives an unselected .nav-tabs .nav-link no
 * fill and a fully transparent border, so on this app's white card the two
 * unselected tabs rendered as bare blue text - visually identical to ordinary
 * hyperlinks sitting in the page title row. Nothing said "these are tabs, and
 * there is more behind them".
 *
 * The fix is to give the strip and the resting tabs a body:
 *   - the strip gets its own tinted band, so it reads as one control rather
 *     than as free-floating text
 *   - an unselected tab gets a fill and a hairline border, so it is legible as
 *     a discrete clickable surface
 *   - the selected tab is white, heavier, and carries the #3c8dbc top edge,
 *     with its bottom border removed so it joins the panel underneath - which
 *     is the cue that says the panel belongs to that tab
 *
 * The #3c8dbc accent was always the intent: the BI page has carried a rule for
 * it since the AdminLTE 4 migration, but in a @push('styles') block, and the
 * layout only renders the 'extraStyles' stack - so it has never applied. It is
 * set here, on the shared component, where it works.
 *
 * Scope is every .nav-tabs in the app, not just the ones wrapped in a
 * .nav-tabs-custom card, so the six strips all behave the same: Business
 * Intelligence (main strip plus the nested Expiring Items strip), Settings,
 * My Profile, and the Dashboard's Expiring Items strip. The Chart of Accounts
 * strip is the one exclusion, via :not(.centered) - it is colour-coded per
 * account class and has its own treatment above.
 *
 * Dark mode deliberately does NOT use white on the unselected tabs. Light grey
 * text on a dark strip glares and, next to a white selected tab, gives the two
 * states too little separation - the selected tab stops looking selected. The
 * unselected label is a muted slate-blue instead, drawn from the same family as
 * the sidebar chrome, and even the selected label is a soft blue-white rather
 * than pure #fff.
 * ------------------------------------------------------------------------- */

.nav-tabs:not(.centered) {
    gap: 3px;
    padding: 6px 8px 0;
    background: #eef2f5;
    border-bottom: 1px solid #d6dde2;
}

.nav-tabs:not(.centered) > .nav-item > .nav-link {
    margin-bottom: -1px;
    padding: 0.45rem 1.1rem;
    color: #40525e;
    font-weight: 500;
    background-color: #e2e8ec;
    border: 1px solid #d6dde2;
    border-top: 3px solid transparent;
    border-radius: 4px 4px 0 0;
}

.nav-tabs:not(.centered) > .nav-item > .nav-link:hover,
.nav-tabs:not(.centered) > .nav-item > .nav-link:focus {
    color: #1f2d35;
    background-color: #f4f7f9;
    border-top-color: #a9c4d4;
}

.nav-tabs:not(.centered) > .nav-item > .nav-link.active {
    color: #2f4b57;
    font-weight: 600;
    background-color: #fff;
    border-color: #d6dde2;
    border-top-color: #3c8dbc;      /* the accent the page always meant to show */
    border-bottom-color: #fff;      /* joins the tab to its panel */
}

/* Dark mode.
 *
 * The rule that matters here is the ORDER of the three surfaces, and getting it
 * wrong is what made an earlier attempt at this read as unchanged. The card the
 * tabs open into is #2b3035; the page behind it is #1b1f22. Painting the
 * selected tab with the page colour made it DARKER than its own panel while the
 * unselected tabs sat lighter than it - the tab metaphor upside down, so nothing
 * looked selected however the text was coloured.
 *
 * Surfaces therefore step upward, exactly as they do in light mode:
 *     strip #1a1f24  <  unselected #212830  <  selected #2b3035 = the panel
 * and the selected tab's bottom border is the panel colour, so the two join.
 *
 * With the surfaces right, both labels can be properly legible rather than one
 * being dimmed to fake a difference: unselected #b7c6d0 at 8.5:1, selected
 * #f2f7fa at 12.3:1. Selection is then carried by four separate cues - surface
 * lift, text brightness, bold weight, and the #3c8dbc top edge - so it survives
 * on a low-quality screen and for a colour-blind reader. */
[data-bs-theme="dark"] .nav-tabs:not(.centered) {
    background: #1a1f24;
    border-bottom-color: #39434a;
}

[data-bs-theme="dark"] .nav-tabs:not(.centered) > .nav-item > .nav-link {
    color: #b7c6d0;
    background-color: #212830;
    border-color: #39434a;
    border-top-color: transparent;
}

[data-bs-theme="dark"] .nav-tabs:not(.centered) > .nav-item > .nav-link:hover,
[data-bs-theme="dark"] .nav-tabs:not(.centered) > .nav-item > .nav-link:focus {
    color: #fff;
    background-color: #2c353d;
    border-top-color: #4a6f88;
}

[data-bs-theme="dark"] .nav-tabs:not(.centered) > .nav-item > .nav-link.active {
    color: #f2f7fa;
    background-color: #2b3035;
    border-color: #39434a;
    border-top-color: #3c8dbc;
    border-bottom-color: #2b3035;
}


/* --- VAT return: row 14 correction, and the account name on row 15 ---------
 * Row 14 was a bare <input class="form"> - not a Bootstrap class, so it got no
 * styling at all - followed by "*range -5000 to 5000" in a red <font> tag. The
 * limit read as an error message rather than as a constraint on the field, and
 * on a narrow screen it wrapped underneath and lost its connection to the box.
 *
 * The input and its range badge are now one inline group, so the badge reads as
 * a property of the field. The numbers in it come from VatReturnHelper, so the
 * badge, the input's min/max and the page's clamping JS cannot disagree.
 *
 * Row 15 printed accounts.name raw - "Tax Control Accounts | ح مراقبة الضرائب",
 * both languages and a pipe, in a cell already carrying its own label. It is a
 * tag now, showing the half that matches the active locale.
 *
 * Colour comes from the .label-warning / .label-primary classes on the markup,
 * the same badge language the ZATCA status labels use, and NOT from here:
 * bs5-compat.css loads after this file and its .label-* rules would win the tie
 * anyway. Only layout is set below, so there is no dead paint to maintain.
 * ------------------------------------------------------------------------- */

.vat-correction {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.vat-correction-input {
    width: 11rem;
    max-width: 100%;
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

.vat-range-hint,
.vat-account-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    padding: 4px 9px;
}

.vat-range-hint { white-space: nowrap; }
.vat-account-tag { white-space: normal; }


/* --- The BI date-range callout -------------------------------------------
 * This one callout is a pale mint rather than one of the saturated callout-*
 * colours, and that put it on the wrong side of the rule further up this file
 * which paints every .callout's text #fff in dark mode. That rule is right for
 * callout-info (#00c0ef) and friends; here it produced white text on a pale
 * mint panel, which is what made "Currently showing results for the last 30
 * days" unreadable as soon as dark mode was on.
 *
 * The fill used to be a style attribute on the div, so no stylesheet could
 * reach it - an inline !important outranks any author rule. As a class it can
 * carry a proper dark surface, and the text colour can then follow the theme
 * instead of being pinned white.
 *
 * Both selectors are (0,2,0)+ so they beat .callout.callout-info and the
 * blanket [data-bs-theme="dark"] .callout * rule, which are (0,2,0) and sit
 * earlier in the file.
 * ------------------------------------------------------------------------- */

.callout.bi-daterange-callout {
    background-color: #e1f0f1 !important;
    border-color: #86b8c0;
}

.callout.bi-daterange-callout,
.callout.bi-daterange-callout * {
    color: #22444d;
}

[data-bs-theme="dark"] .callout.bi-daterange-callout {
    background-color: #1e2f36 !important;
    border-color: #35606b;
}

[data-bs-theme="dark"] .callout.bi-daterange-callout,
[data-bs-theme="dark"] .callout.bi-daterange-callout * {
    color: #d3e6ea;
}


/* --- Wide tables on a phone ------------------------------------------------
 * Measured at a 360px viewport: the VAT return overflowed the page by 191px,
 * because its five-column table needs 408px and nothing let it scroll. The page
 * itself then scrolled sideways, which drags the whole layout - header, sidebar
 * toggle and all - off screen.
 *
 * The table is made its own scroll container instead, so it slides horizontally
 * inside a page that stays put. This is the display:block technique rather than
 * a .table-responsive wrapper, deliberately: the VAT return tables live in a
 * partial SHARED WITH THE PRINTABLE PDF, and touching that markup risks the one
 * output ZATCA and auditors actually read. A stylesheet cannot reach the PDF at
 * all - layouts/partials/print_styles loads the frozen Bootstrap 3 set and never
 * loads this file - so doing it here is provably safe for print.
 *
 * DataTables tables are excluded. They measure and write their own widths, and
 * eleven of them sit inside modals with a width workaround already; making one
 * display:block underneath that would fight it.
 *
 * The breakpoint is the tablet one, not the phone one: these tables are wide
 * enough to need this on a small tablet in portrait too.
 * ------------------------------------------------------------------------- */

@media (max-width: 991.98px) {
    .box-body > table:not(.dataTable),
    .box-body > form > table:not(.dataTable),
    .table-scroll {
        display: block;
        width: max-content;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ---------------------------------------------------------------------------
 * SweetAlert2 in dark mode
 *
 * The library hardcodes `background:#fff; color:#545454` on .swal2-popup and
 * ships no dark rules at all, so every dialog in the application - v4gAlert,
 * v4gConfirm, the after-save prompt, the scan-code capture - stayed a white
 * card on the dark UI.
 *
 * That is readable by luck rather than design, and it fails outright for any
 * muted text inside a dialog: Bootstrap 5.3 redefines --bs-secondary-color for
 * dark mode as a LIGHT grey, so `.text-muted` renders light-on-white and
 * disappears. It is the same trap as the table cells documented in CLAUDE.md -
 * the text colour and the background it lands on are decided by different
 * rules, and only one of them knew the theme had changed.
 *
 * Scoped to [data-bs-theme="dark"], never to prefers-color-scheme: this app
 * pins its own theme and deliberately ignores the OS preference.
 *
 * Surfaces match the dark panels above (#2b3035 on #1b1f22, borders #3a4046),
 * so a dialog reads as part of the same interface rather than a second one.
 * The action buttons need nothing: every dialog here is built with
 * buttonsStyling:false and wears the app's own .btn classes.
 * ------------------------------------------------------------------------- */

[data-bs-theme="dark"] .swal2-popup {
    background: #2b3035;
    color: #dee2e6;
    /* Bootstrap gives a dark .modal-content an edge; without one the dialog
       floats with no boundary against the dimmed page behind it. */
    border: 1px solid #3a4046;
}

/* Both inherit the popup's colour, but say so rather than depend on it. */
[data-bs-theme="dark"] .swal2-title,
[data-bs-theme="dark"] .swal2-html-container {
    color: #dee2e6;
}

/* The close X and the "no image" icon rings sit on the popup, not the page. */
[data-bs-theme="dark"] .swal2-close {
    color: #adb5bd;
}

[data-bs-theme="dark"] .swal2-close:hover {
    color: #f5f5f5;
}

/* Inputs are only used by Swal.fire({input:...}), but a white box with dark
   text inside a dark dialog is the same bug one level down. */
[data-bs-theme="dark"] .swal2-input,
[data-bs-theme="dark"] .swal2-file,
[data-bs-theme="dark"] .swal2-textarea,
[data-bs-theme="dark"] .swal2-select {
    background: #22262a;
    border-color: #3a4046;
    color: #dee2e6;
}

[data-bs-theme="dark"] .swal2-input::placeholder,
[data-bs-theme="dark"] .swal2-textarea::placeholder {
    color: #8b949e;
}

[data-bs-theme="dark"] .swal2-validation-message {
    background: #3d1f1f;
    color: #edb5b5;
}

/* A touch deeper than the light backdrop: the same 40% black over a dark page
   barely separates the dialog from it. */
[data-bs-theme="dark"] .swal2-container.swal2-backdrop-show {
    background: rgba(0, 0, 0, 0.6);
}

/* ---------------------------------------------------------------------------
 * Select2 in dark mode
 *
 * Same shape of problem as SweetAlert2 above, and the same cause. Select2's
 * stylesheet hardcodes `background-color: white` on both .select2-dropdown and
 * the closed .select2-selection--single, and ships nothing for dark mode - but
 * .select2-results__option sets no colour at all, so the options inherit the
 * page's text colour, which in dark mode is a LIGHT grey. Light grey text on
 * the library's white panel is what made the choices almost unreadable, while
 * the ordinary inputs a few pixels below were already dark.
 *
 * The values are taken from what .form-control actually computes to in dark
 * mode on this app (#343a40 on a #495057 border, #dee2e6 text), measured rather
 * than guessed, so a select sits in a form looking like the fields around it.
 *
 * Scoped to [data-bs-theme="dark"], never prefers-color-scheme: this app pins
 * its own theme. The dropdown is appended to <body> and the attribute is on
 * <html>, so these still match when it is open.
 *
 * Only the "default" select2 theme is covered, which is the one this app uses.
 * ------------------------------------------------------------------------- */

/* The closed control. */
[data-bs-theme="dark"] .select2-container--default .select2-selection--single,
[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple {
    background-color: #343a40;
    border-color: #495057;
}

[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #dee2e6;
}

[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__placeholder,
[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__placeholder {
    color: #8b949e;
}

/* The caret, in both the closed and open states. */
[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-top-color: #adb5bd;
}

[data-bs-theme="dark"] .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-bottom-color: #adb5bd;
    border-top-color: transparent;
}

/* The panel. */
[data-bs-theme="dark"] .select2-dropdown {
    background-color: #343a40;
    border-color: #495057;
}

/* The options. Given a colour explicitly - inheriting one is the whole bug. */
[data-bs-theme="dark"] .select2-container--default .select2-results__option {
    color: #dee2e6;
}

/* The row that is already chosen. #ddd from the library is a light-mode value. */
[data-bs-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: #495057;
    color: #fff;
}

/* The keyboard/hover row, in BOTH themes.
 *
 * Select2 paints it #5897fb with white text, which measures 2.90:1 - well under
 * the 4.5:1 normal text needs, and the row under the cursor is the one being
 * read. #337ab7 is this app's pinned Bootstrap 3 primary (see the palette note
 * above), so it introduces no new colour and clears the bar at 4.56:1.
 *
 * Not scoped to dark: the weakness is in the library's own light-mode value, and
 * the row is equally hard to read there. */
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #337ab7;
    color: #fff;
}

[data-bs-theme="dark"] .select2-container--default .select2-results__option[aria-disabled="true"] {
    color: #6c757d;
}

/* The search box inside the dropdown. */
[data-bs-theme="dark"] .select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: #2b3035;
    border-color: #495057;
    color: #dee2e6;
}

[data-bs-theme="dark"] .select2-container--default .select2-search--inline .select2-search__field {
    color: #dee2e6;
}

/* Multi-select pills. */
[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #495057;
    border-color: #5c636a;
    color: #dee2e6;
}

[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #adb5bd;
}

[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #fff;
}

/* Disabled, which the library paints #eee. */
[data-bs-theme="dark"] .select2-container--default.select2-container--disabled .select2-selection--single,
[data-bs-theme="dark"] .select2-container--default.select2-container--disabled .select2-selection--multiple {
    background-color: #2b3035;
    color: #6c757d;
}

/* --- "no direct entries" tag in the account dropdowns -----------------------
 * The bracketed note select2 draws beside the chart's aggregate accounts on the
 * accounting-note form (transactions/add). Its own colour, rather than AdminLTE's
 * .text-orange, because that orange is #ff851b and measures 2.44:1 on the white
 * dropdown - too low to read at the small size this renders at.
 *
 * Measured: #b35a00 on white 4.80:1; #ff9f43 on the dark dropdown (#343a40) 5.64:1
 * and on the dark panel (#2b3035) 6.53:1. Both are still plainly orange.
 */
.acct-blocked-tag {
    color: #b35a00;
    font-style: italic;
}

[data-bs-theme="dark"] .acct-blocked-tag {
    color: #ff9f43;
}

/* The submit button while a blocked account is selected. Wears the notice's own colours
 * so the button and the explanation read as one thing: #f39c12 with #212529 text and the
 * #e08e0b edge, measured off the rendered .callout-warning rather than assumed, and the
 * same in both themes because the callout itself is (its amber is a light surface, so it
 * keeps dark text either way - see the callout note above).
 *
 * Set through Bootstrap's own button variables, INCLUDING the disabled ones: the button
 * is disabled whenever this class is on it, and .btn:disabled otherwise repaints it from
 * --bs-btn-disabled-bg and drops it to 65% opacity, which greys out the very colour this
 * is here to show. Opacity stays 1 and `not-allowed` carries the "you cannot press this",
 * along with the label, which says so in words.
 */
.btn-account-blocked {
    --bs-btn-bg: #f39c12;
    --bs-btn-color: #212529;
    --bs-btn-border-color: #e08e0b;
    --bs-btn-disabled-bg: #f39c12;
    --bs-btn-disabled-color: #212529;
    --bs-btn-disabled-border-color: #e08e0b;
    --bs-btn-disabled-opacity: 1;
    cursor: not-allowed;
}

/* The row under the cursor is painted #337ab7 with white text, in BOTH themes, so the
 * tag has to be re-coloured for it - and it is the row being read. Measured on that
 * blue: the light tag gives 1.05:1 and the dark one 2.23:1, i.e. invisible and barely
 * legible. No orange can reach 4.5:1 there (it would have to be within a hair of white),
 * so the tag takes the row's own colour, 4.56:1, and stays italic and bracketed to read
 * as an aside. Out-specifies both rules above on its own, so it needs no dark twin.
 */
.select2-container--default .select2-results__option--highlighted[aria-selected] .acct-blocked-tag {
    color: #fff;
}

/* --- B2B / B2C marker on the invoice template tiles -------------------------
 * Sits in the tile's info-box-text slot, on the saturated .info-box fills
 * (bg-aqua, bg-green, bg-yellow...). Both badges are dark text on a light plate,
 * identical in light and dark mode, because the tile's own background is the
 * variable here - not the theme - and a badge that inherited the theme's
 * foreground would vanish on some tiles and not others. Same reasoning as the
 * POS tile: the tile is not the theme.
 */
.audience-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .3px;
    line-height: 1.6;
    background: #ffffff;
    /* !important, and matched through .info-box so it also outranks the tile's own
       colour helper. The tiles are .info-box.bg-aqua / .bg-green / .bg-yellow..., and
       those helpers paint EVERY descendant `color: #fff !important` - which landed white
       text on this badge's pale plate at 1.21:1. The background came through and the
       colour did not, which is exactly the half-applied look that hides this class of
       bug: the badge appeared, it was simply unreadable. */
    color: #1e282c !important;
    border: 1px solid rgba(0, 0, 0, .15);
}
.info-box .audience-badge,
.info-box-content .audience-badge { color: #1e282c !important; }
/* Told apart by a tint rather than by hue alone, so the distinction survives a
   greyscale print and colour-blind readers. Neither reads as good or bad. */
.audience-badge.audience-b2b { background: #dbe9f5; }
.audience-badge.audience-b2c { background: #f7e8cf; }

/* --- Checkbox on the financial statement reports ----------------------------
 * The same treatment Settings gives its ~25 bare checkboxes: bigger, rounded and
 * accent-coloured through the standard `accent-color` property, with no markup
 * change. Settings scopes its rule to .tab-content, which does not reach these
 * reports, so the class carries it here rather than the rule being widened - the
 * point is to match that look, not to restyle every checkbox in the app.
 */
.fin-check {
    width: 1.15em;
    height: 1.15em;
    margin-inline-end: 0.4em;
    vertical-align: middle;
    accent-color: #337ab7;
    cursor: pointer;
}
