:root {
    --sidebar: #14212e;
    --sidebar-2: #0f1a24;
    --brand: #0fac9c;
    --brand-d: #0a8a7d;
    --brand-soft: rgba(15, 172, 156, .12);
    --orange: #f26522;
    --ink: #1c2b39;
    --muted: #6b7b8a;
    --line: #e8ecf1;
    --bg: #f4f6f9;
    --up: #0fac6c;
    --down: #e7413a;
    --card-r: 16px;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);

    /* Surfaces. Every panel/card/control in this stylesheet paints with these
       rather than a literal white, so the dark block below is all it takes to
       flip the whole app. (`color: #fff` elsewhere is text sitting ON the
       brand or the sidebar - that stays white in both themes.) */
    --surface: #fff;        /* cards, topbar, inline controls */
    --surface-2: #fff;      /* elevated: dropdown panels, popovers */
    --surface-3: #fff;      /* highest: modals */
    --surface-hover: #f4f6f9;   /* hovered row / menu item / ghost button */
    --input-bg: #fff;       /* text fields */
    --scrollbar-thumb: #c8d2dc;

    /* A second, firmer border for things that need to hold their own edge
       against the surface behind them (modals, outline buttons, inputs on
       hover). On white these are barely distinguishable from --line; on dark
       the difference is what stops everything reading as one flat sheet. */
    --line-strong: #dbe2e9;
    --table-head: transparent;
    --overlay: rgba(16, 24, 40, .5);        /* modal backdrop */
    --shadow-raised: 0 16px 36px -14px rgba(20, 33, 46, .28);
    --glow-accent: none;    /* dark-only: soft accent halo on active/primary */

    /* Greys that sit on a surface. Three roles rather than one because the
       design uses three weights; they converge on a single value in dark. */
    --ink-ctl: #5b6b7a;     /* glyph inside a control (icon button) */
    --ink-tile: #7c8b99;    /* glyph inside a filled icon tile */
    --ink-meta: #54636f;    /* dense metadata text */

    --line-soft: #f1f4f7;   /* hairline divider between rows inside a card */
    --fill: #f2f5f8;        /* filled icon tile */
    --fill-2: #eef1f4;      /* inactive tab */
    --skel-1: #eceff2;      /* loading shimmer, trough */
    --skel-2: #f6f8fa;      /* loading shimmer, crest */

    --input-border: #d7dee5;
    --input-border-2: #c7d0d9;  /* checkbox / hover */
    --input-addon-bg: #fbfcfd;  /* .input-group-text, a hair off the field */
    --placeholder: #9aa7b3;

    /* Status tints. Reused by alerts, payment pills and expiry rows. */
    --danger-soft: #fdeceb;  --danger-line: #f6d9d6;  --danger-ink: #a3312b;
    --success-soft: #e7f8f0; --success-line: #cdeee0; --success-ink: #0a8a5f;
    --warning-soft: #fdf1e6; --warning-line: #f7e3c6; --warning-ink: #9a5b16;

    /* Badge/pill washes. These exact pastels were repeated as literals across
       ~60 views (status pills, activity rows, timeline chips), always paired
       with a token for the text - `background: var(--tint-green); color:
       var(--up)` and so on. As tokens they flip to translucent washes in dark
       while the paired text token lifts itself. */
    --tint-brand: #eafaf4;
    --tint-green: #e2f6ec;
    --tint-red: #fdecec;
    --tint-indigo: #eef2ff;
    --tint-sel: #e2f5f3;    /* keyboard/selected row in a picker */
    --indigo: #4a63f0;      /* the one saturated accent that is not --brand */

    /* An inset panel a hair off the card behind it - read-only boxes, modal
       backdrops, grouped sub-forms. Several near-identical off-whites across
       the views collapse onto this. */
    --panel: #f8fafc;
}

/*  Dark theme
    ----------
    Keyed off Bootstrap 5.3's own `data-bs-theme` attribute so one switch
    drives both: Bootstrap themes its components (modals, dropdowns, tables,
    forms, pagination, alerts) from it, and the tokens below re-point this
    stylesheet. Kept separate from `data-theme` above, which is the business's
    brand colour and is orthogonal to light/dark.

    Deep charcoal rather than black, with cards a step lighter than the page
    and fields a step darker, so content hierarchy survives.

    Scoped to `screen` on purpose: on paper the tokens fall back to the light
    `:root` values above, so a receipt, label or report printed while the
    screen is dark still comes out on white with black text. See the
    `@media print` block at the foot of this file, which does the same for
    Bootstrap's own dark variables. */
@media screen {
    html[data-bs-theme="dark"] {
        /*  Surface ladder. Six steps, each one a measured notch lighter than
            the last, because on dark it is CONTRAST BETWEEN SURFACES - not
            shadow - that carries depth. Blue-cast charcoal rather than neutral
            grey or black: it reads as considered rather than switched-off, and
            it is easier to sit in front of all day.

                #07 0b 10   page          the deepest thing on screen
                #0b 11 18   sidebar/topbar chrome, framing the work
                #11 19 22   surface       cards, the content plane
                #17 212c    surface-2     dropdowns, popovers
                #1d 2733    surface-3     modals, the top of the stack
                #0c 131a    input         RECESSED - fields read as cut into
                                          the card, not floating on it        */
        --bg: #070b10;
        --sidebar: #0b1118;
        --sidebar-2: #080d13;
        --surface: #111922;
        --surface-2: #17212c;
        --surface-3: #1d2733;
        --surface-hover: #1b2532;
        --input-bg: #0c131a;

        /* Text hierarchy: never pure white. Three weights so a card's title,
           its value and its label are told apart by colour, not just size. */
        --ink: #e9eff6;
        --muted: #94a5b7;

        /* Borders do a lot of the structural work on dark, so --line is set at
           the point it defines an edge without drawing attention to itself
           (1.36:1 against the card); --line-strong is for things that must
           hold their own outline - modals, outline buttons, table heads. */
        --line: #263241;
        --line-strong: #344357;

        /* the accent needs more presence as a tint on dark than it does on white */
        --brand-soft: rgba(15, 172, 156, .18);
        /* semantic colours lifted until they read against a dark surface */
        --up: #35d08a;
        --down: #ff6b61;

        /* Dark leans on borders and surface steps; shadow is a quiet
           supporting role, not the thing doing the work. */
        --shadow-card: 0 1px 2px rgba(0, 0, 0, .5), 0 2px 10px -4px rgba(0, 0, 0, .35);
        --shadow-raised: 0 18px 44px -16px rgba(0, 0, 0, .8), 0 2px 10px -4px rgba(0, 0, 0, .5);
        --overlay: rgba(4, 7, 11, .74);
        --glow-accent: 0 0 20px -6px rgba(15, 172, 156, .55);

        --table-head: #151e28;
        --scrollbar-thumb: #2c3a48;

        /* the three light greys converge - on a dark surface they'd all be too
           close to the background to stay apart */
        --ink-ctl: #b3c2cf;
        --ink-tile: #9bacbd;
        --ink-meta: #a7b6c4;

        --line-soft: #1c2631;
        --fill: #1a232e;
        --fill-2: #161f29;
        --panel: #0f161e;
        --skel-1: #18212b;
        --skel-2: #222d3a;

        --input-border: #2b3745;
        --input-border-2: #374556;
        --input-addon-bg: #161f29;
        --placeholder: #76858f;

        /* Status tints become translucent washes of the semantic colour rather
           than pastels, and the text lifts well clear of AA on the dark surface. */
        --danger-soft: rgba(231, 65, 58, .16);  --danger-line: rgba(231, 65, 58, .34);  --danger-ink: #ff9b93;
        --success-soft: rgba(15, 172, 108, .16); --success-line: rgba(15, 172, 108, .34); --success-ink: #6fe0ae;
        --warning-soft: rgba(242, 101, 34, .16); --warning-line: rgba(242, 101, 34, .34); --warning-ink: #f3b27c;

        /* Washes rather than pastels, so the paired text token still reads. */
        --tint-brand: rgba(15, 172, 156, .16);
        --tint-green: rgba(15, 172, 108, .18);
        --tint-red: rgba(231, 65, 58, .18);
        --tint-indigo: rgba(110, 133, 255, .20);
        --tint-sel: rgba(15, 172, 156, .26);
        --indigo: #8ea4ff;
    }
}

/* Business Settings > System > Theme Color (business.theme_color) - swaps the
   brand accent (--brand / --brand-d / --brand-soft, used pervasively across
   this stylesheet) for the color the business picked. Set via data-theme on
   <html> in layouts/app.blade.php. "primary" is the built-in default above,
   so it has no override block here. */
html[data-theme="purple"] { --brand: #7c3aed; --brand-d: #6d28d9; --brand-soft: rgba(124, 58, 237, .12); }
html[data-theme="green"]  { --brand: #16a34a; --brand-d: #15803d; --brand-soft: rgba(22, 163, 74, .12); }
html[data-theme="red"]    { --brand: #dc2626; --brand-d: #b91c1c; --brand-soft: rgba(220, 38, 38, .12); }
html[data-theme="yellow"] { --brand: #ca8a04; --brand-d: #a16207; --brand-soft: rgba(202, 138, 4, .12); }
html[data-theme="orange"] { --brand: #ea580c; --brand-d: #c2410c; --brand-soft: rgba(234, 88, 12, .12); }
html[data-theme="sky"]    { --brand: #0ea5e9; --brand-d: #0284c7; --brand-soft: rgba(14, 165, 233, .12); }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 8px; }
.text-brand { color: var(--brand) !important; }
.up { color: var(--up); }
.down { color: var(--down); }

/* ---------- layout shell ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex: 0 0 240px;
    background: var(--sidebar);
    color: #aeb9c4;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 24px;
    scrollbar-width: thin;
    scrollbar-color: #33424f transparent;
    transition: width .2s ease;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #33424f; border-radius: 6px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #445565; }

.brandbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    position: sticky;
    top: 0;
    background: var(--sidebar);
    z-index: 5;
}

.brandbar .logo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
    font-size: 20px;
    color: #fff;
    min-width: 0;
    flex: 1 1 auto;
}

.brandbar .logo .mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--brand-d), #24d3bd);
    color: #fff;
    font-size: 15px;
    flex: 0 0 auto;
}

.brandbar .logo .logo-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Long business names: step the font size down before it ever needs to truncate. */
.brandbar .logo .logo-text:not(:empty) { font-size: clamp(13px, 4.4vw, 20px); }
@media (min-width: 992px) { .brandbar .logo .logo-text { font-size: 17px; } }

.nav-group { padding: 2px 12px; }

.nav-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #5f7182;
    font-weight: 700;
    padding: 14px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 9px;
    color: #aeb9c4;
    font-weight: 500;
    font-size: 13.5px;
    margin-bottom: 1px;
    cursor: pointer;
    transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}

.nav-item i:first-child { width: 18px; text-align: center; font-size: 14px; color: #7b8b99; transition: color .18s ease; }
.nav-item:hover { background: #1c2c3a; color: #fff; }
.nav-item:hover i:first-child { color: #cdd6de; }
.nav-item.active {
    background: var(--brand); color: #fff; font-weight: 700;
    box-shadow: inset 3px 0 0 rgba(255, 255, 255, .85), 0 6px 16px rgba(15, 172, 156, .35);
}
.nav-item.active i:first-child { color: #fff; }

/* ---------- collapsible nav sections (grouped sidebar dropdowns) ---------- */
.nav-section { margin-bottom: 1px; }

.nav-section-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 9px 12px;
    border-radius: 9px;
    border: none;
    background: none;
    color: #c7d0d9;
    font-weight: 600;
    font-size: 13.5px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background .18s ease, color .18s ease;
}
.nav-section-toggle:hover { background: #1c2c3a; color: #fff; }
.nav-section-toggle:hover .nav-section-icon { color: #cdd6de; }

.nav-section-icon { width: 18px; text-align: center; font-size: 14px; color: #7b8b99; flex: 0 0 auto; transition: color .18s ease; }
.nav-section-label { flex: 1 1 auto; min-width: 0; }
.nav-section-chevron {
    font-size: 11px;
    color: #5f7182;
    flex: 0 0 auto;
    transition: transform .2s ease, color .18s ease;
}
.nav-section-toggle:not(.collapsed) .nav-section-chevron { transform: rotate(180deg); }

/* A collapsed group whose current page lives inside it - a lighter cue than
   the full solid .nav-item.active treatment, since the toggle itself isn't a page. */
.nav-section-toggle.active { color: var(--brand); font-weight: 700; }
.nav-section-toggle.active .nav-section-icon,
.nav-section-toggle.active .nav-section-chevron { color: var(--brand); }

/* Smoother, snappier collapse/expand than Bootstrap's 0.35s default. */
.nav-section .collapsing { transition-duration: .2s; }

.nav-section-body {
    padding-left: 14px;
    border-left: 1px solid rgba(255, 255, 255, .06);
    margin: 2px 0 4px 21px;
}
.nav-section-body .nav-item { padding-left: 10px; }

@media (min-width: 1101px) {
    html.sidebar-collapsed .nav-section-toggle { display: none; }
    html.sidebar-collapsed .nav-section-body { margin: 0; padding: 0; border: none; }
    html.sidebar-collapsed .nav-section .collapse { display: block !important; height: auto !important; }
}

/* ---------- Sidebar collapse (icon-only), desktop/tablet only ---------- */
.sidebar-collapse-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    border: none;
    background: rgba(255, 255, 255, .08);
    color: #aeb9c4;
    cursor: pointer;
    flex: 0 0 auto;
}
.sidebar-collapse-toggle:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.sidebar-collapse-toggle i { transition: transform .18s ease; }

@media (min-width: 1101px) {
    .sidebar-collapse-toggle { display: inline-flex; }

    html.sidebar-collapsed .sidebar { width: 76px; flex: 0 0 76px; }
    html.sidebar-collapsed .brandbar { flex-direction: column; gap: 12px; padding: 16px 8px; }
    html.sidebar-collapsed .brandbar .logo { font-size: 0; gap: 0; }
    html.sidebar-collapsed .brandbar .logo .logo-text { display: none; }
    html.sidebar-collapsed .sidebar-collapse-toggle i { transform: rotate(180deg); }
    html.sidebar-collapsed .nav-group { padding: 2px 6px; }
    html.sidebar-collapsed .nav-label { display: none; }
    html.sidebar-collapsed .nav-item { justify-content: center; gap: 0; padding: 10px 0; font-size: 0; }
    html.sidebar-collapsed .nav-item i:first-child { width: auto; font-size: 16px; }
}

/* ---------- main ---------- */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 26px;
}

.topbar h5 { margin: 0; font-weight: 800; font-size: 18px; }

.icon-btn {
    border: 1px solid var(--line);
    background: var(--surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--ink-ctl);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    position: relative;
}

/* Light/dark switch (partials/theme-toggle). Only one of the two icons is
   ever shown, chosen by the attribute itself so the button is right on the
   first paint rather than after JS runs. */
.theme-toggle { cursor: pointer; transition: color .18s ease, border-color .18s ease, background .18s ease; }
.theme-toggle:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
/* The sun's rays need room to read as rays rather than as a serrated edge;
   at the inherited 14px they close up and the glyph starts looking like a cog. */
.theme-toggle i { font-size: 16px; line-height: 1; }
.theme-toggle .theme-ic-light { display: none; }
html[data-bs-theme="dark"] .theme-toggle .theme-ic-dark { display: none; }
html[data-bs-theme="dark"] .theme-toggle .theme-ic-light { display: inline; }

.icon-btn .dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--up);
    border: 2px solid var(--surface);
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
}

.content { padding: 26px; display: flex; flex-direction: column; gap: 22px; }

/* ---------- welcome ---------- */
.welcome h1 { font-size: 30px; font-weight: 800; margin: 0; }
.welcome .sub { color: var(--muted); margin-top: 6px; font-size: 13.5px; display: flex; align-items: center; }

/* Entrance: whole greeting block fades + settles in on load */
@keyframes welcome-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* The fill-mode keeps a transform on the block, making it a stacking context
   that traps the date/location dropdown panels' z-index - lift the whole
   header above the (also animated) cards below so those panels open on top. */
.welcome--animated { animation: welcome-in .5s cubic-bezier(.16, 1, .3, 1) both; position: relative; z-index: 10; }

/* Little Teciga robot mascot - full character (head, jointed arms, torso
   with the TECIGA wordmark on its chest) that waves periodically to say hi.
   Powers on with a mechanical snap when the dashboard loads. Sits as its
   own flex item next to the greeting text (see .welcome-hero), not inline
   within it, so it can be sized generously without cramping the heading. */
.welcome-hero { min-width: 0; gap: 1.35rem; }
.hi-bot {
    display: inline-flex; flex: 0 0 auto; position: relative;
    filter: drop-shadow(0 8px 14px rgba(10, 138, 125, .32));
    animation: hi-bot-in .55s cubic-bezier(.34, 1.56, .64, 1) .45s both;
}
.hi-bot svg { display: block; position: relative; z-index: 1; }
/* Soft glow behind the mascot so it reads as a featured element, not just
   another icon, without introducing a hard-edged badge/background shape. */
.hi-bot::before {
    content: ""; position: absolute; z-index: 0;
    left: 50%; bottom: 6%; width: 92%; height: 78%;
    transform: translateX(-50%);
    background: radial-gradient(closest-side, var(--brand-soft), transparent);
    border-radius: 50%;
}
@keyframes hi-bot-in {
    0% { opacity: 0; transform: scale(.35) rotate(-30deg); }
    60% { opacity: 1; transform: scale(1.12) rotate(6deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* Chest light blink */
.bot-led { animation: bot-led-blink 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes bot-led-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* Waving arm - pivots at the shoulder joint (60,110 in the SVG's own
   viewBox), waves for a moment, then rests; repeats every few seconds so
   the mascot stays lively without being distracting. */
.bot-arm {
    transform-box: view-box;
    transform-origin: 60px 110px;
    animation: bot-wave 6s ease-in-out infinite;
    animation-delay: 1s;
}
@keyframes bot-wave {
    0% { transform: rotate(0deg); }
    3% { transform: rotate(-16deg); }
    6% { transform: rotate(12deg); }
    9% { transform: rotate(-12deg); }
    12% { transform: rotate(8deg); }
    16% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

/* "Hi!" speech bubble - pops in right as the arm starts waving, holds for a
   moment, then fades until the next wave cycle. Same 6s loop/delay as
   .bot-arm so both stay in sync. */
.bot-hi {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    opacity: 0;
    animation: bot-hi-pop 6s ease-in-out infinite;
    animation-delay: 1s;
}
@keyframes bot-hi-pop {
    0% { opacity: 0; transform: scale(.5); }
    6% { opacity: 1; transform: scale(1.08); }
    10% { transform: scale(1); }
    28% { opacity: 1; transform: scale(1); }
    36% { opacity: 0; transform: scale(.85); }
    100% { opacity: 0; }
}

/* Brand-gradient accent bar sweeping in under the heading */
@keyframes welcome-underline {
    from { width: 0; opacity: 0; }
    to { width: 64px; opacity: 1; }
}
.welcome-underline {
    height: 3px; width: 64px; border-radius: 3px; margin-top: 8px;
    background: linear-gradient(90deg, var(--brand), #1ec8b4);
    animation: welcome-underline .6s cubic-bezier(.16, 1, .3, 1) .3s both;
}

/* Small pulsing "live data" dot next to the date */
.live-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--up); margin-right: 7px; flex: 0 0 auto;
    animation: live-pulse 2.2s ease-out infinite;
}
@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(15, 172, 108, .5); }
    70% { box-shadow: 0 0 0 6px rgba(15, 172, 108, 0); }
    100% { box-shadow: 0 0 0 0 rgba(15, 172, 108, 0); }
}

.btn-pos {
    background: var(--orange);
    color: #fff !important;
    border: none;
    border-radius: 9px;
    padding: 9px 18px;
    font-weight: 700;
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.btn-pos:hover { background: #d8531a; }

/* ---------- topbar POS button ----------
   The original, pre-existing quick-access POS link (layouts/app.blade.php) -
   its own class, not a .btn-pos edit, so this styling stays scoped to that
   one button instead of every Save/Submit/Complete-Sale button sitewide
   that also uses .btn-pos. */
.topbar-pos-btn {
    background: linear-gradient(135deg, #ff8a4c, var(--orange) 55%, #d8531a);
    color: #fff !important;
    border: none;
    border-radius: 12px;
    padding: 11px 22px;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: .01em;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    box-shadow: 0 6px 18px -4px rgba(242, 101, 34, .6);
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.topbar-pos-btn i.fa-cash-register { font-size: 16px; transition: transform .16s ease; }
.topbar-pos-arrow {
    font-size: 12px; max-width: 0; opacity: 0; overflow: hidden;
    transition: max-width .18s ease, opacity .18s ease;
}
.topbar-pos-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, #ff9d5c, #ff7a3d 55%, var(--orange));
    box-shadow: 0 10px 24px -6px rgba(242, 101, 34, .7);
}
.topbar-pos-btn:hover i.fa-cash-register { transform: scale(1.12) rotate(-6deg); }
.topbar-pos-btn:hover .topbar-pos-arrow { max-width: 16px; opacity: 1; }
.topbar-pos-btn:active { transform: translateY(0) scale(.97); box-shadow: 0 4px 12px -6px rgba(242, 101, 34, .55); }
.topbar-pos-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 4px rgba(242, 101, 34, .35); }

@media (max-width: 640px) {
    .topbar-pos-btn { padding: 8px 14px; font-size: 13px; border-radius: 10px; gap: 7px; }
    .topbar-pos-btn i.fa-cash-register { font-size: 13px; }
}

.btn-plain {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 9px;
    padding: 9px 14px;
    font-weight: 600;
    font-size: 13px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--ink);
}

/* ---------- topbar help button + dropdown ---------- */
.help-btn {
    border: 1px solid transparent;
    background: linear-gradient(135deg, var(--brand), var(--brand-d));
    border-radius: 999px;
    padding: 9px 16px;
    font-weight: 700;
    font-size: 13px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 18px -8px rgba(15, 172, 156, .55);
    transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}

.help-btn i { color: #fff; font-size: 14px; }
.help-btn:hover, .help-btn[aria-expanded="true"] {
    background: linear-gradient(135deg, var(--brand-d), var(--brand-d));
    box-shadow: 0 12px 26px -8px rgba(15, 172, 156, .75);
    transform: translateY(-1px);
}
.help-btn:active { transform: translateY(0); }

.help-menu {
    width: 280px;
    max-width: calc(100vw - 24px);
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 24px 52px -18px rgba(20, 33, 46, .3);
    margin-top: 12px !important;
    overflow: hidden;
}

.help-menu.show { animation: help-menu-in .2s cubic-bezier(.16, 1, .3, 1); }

@keyframes help-menu-in {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to { opacity: 1; transform: none; }
}

.help-menu-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    padding: 0 4px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}

.help-menu-title::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand);
    flex: 0 0 auto;
}

.help-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 8px;
    border-radius: 11px;
    text-decoration: none;
    color: inherit;
    transition: background .15s ease, transform .15s ease;
}

.help-menu-item:hover { background: var(--surface-hover); transform: translateX(2px); }
.help-menu-item:hover .hm-ic { transform: scale(1.08); }

.help-menu-item .hm-ic {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex: 0 0 36px;
    background: rgba(15, 172, 156, .1);
    color: var(--brand-d);
    display: grid;
    place-items: center;
    font-size: 14px;
    transition: transform .15s ease;
}

.help-menu-item .hm-ic.call { background: rgba(15, 172, 156, .1); color: var(--brand-d); }
.help-menu-item .hm-ic.wa { background: rgba(37, 211, 102, .14); color: #1eb655; }
.help-menu-item .hm-ic.email { background: rgba(242, 101, 34, .1); color: var(--orange); }
.help-menu-item .hm-ic.ticket { background: rgba(74, 99, 240, .12); color: var(--indigo); }

.help-menu-item .hm-txt { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }

.help-menu-item .hm-lbl {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.help-menu-item .hm-val { font-size: 13px; font-weight: 700; color: var(--ink); word-break: break-word; }

/* Support Tickets entry: its own elevated, professional CTA card - deliberately
   the visual high point of the Help menu, distinct from the plain Call/WhatsApp/
   Email rows above it. */
.help-menu-item--ticket {
    margin-top: 12px;
    padding: 13px 14px;
    background: var(--brand-d);
    border-radius: 14px;
    box-shadow: 0 8px 18px -10px rgba(10, 138, 125, .45);
    transition: box-shadow .15s ease, transform .15s ease;
}
.help-menu-item--ticket:hover {
    background: var(--brand-d);
    box-shadow: 0 10px 22px -8px rgba(10, 138, 125, .55);
    transform: translateY(-1px);
}
.help-menu-item--ticket .hm-ic.ticket {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    font-size: 17px;
    background: rgba(255, 255, 255, .18);
    color: #fff;
}
.help-menu-item--ticket:hover .hm-ic { transform: none; }
.help-menu-item--ticket .hm-txt { flex: 1 1 auto; }
.help-menu-item--ticket .hm-lbl { color: rgba(255, 255, 255, .82); letter-spacing: .06em; }
.help-menu-item--ticket .hm-val { color: #fff; font-size: 14px; }
.help-menu-item--ticket::after {
    content: "\f105";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 14px;
    color: rgba(255, 255, 255, .75);
    flex: 0 0 auto;
}

/* ---------- attachment dropzone ---------- */
.dropzone {
    border: 2px dashed var(--line);
    border-radius: 12px;
    padding: 22px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
    color: var(--muted);
}
.dropzone:hover, .dropzone.dz-active { border-color: var(--brand); background: rgba(15, 172, 156, .05); }
.dropzone i { font-size: 22px; color: var(--brand); margin-bottom: 6px; display: block; }
.dz-filelist { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.dz-filelist li {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 7px 10px; background: var(--bg); border-radius: 8px; font-size: 12.5px;
}
.dz-filelist .dz-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dz-filelist .dz-size { color: var(--muted); flex: 0 0 auto; }
.dz-filelist .dz-remove { color: var(--down); cursor: pointer; flex: 0 0 auto; background: none; border: none; font-size: 14px; }

/* ---------- cards ---------- */
.card2 {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--card-r);
    padding: 20px;
    box-shadow: var(--shadow-card);
}

.card-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.card-h h3 { font-size: 17px; font-weight: 800; margin: 0; letter-spacing: -.01em; }

.round-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface);
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 12px;
}

/* ---------- stat strip ---------- */
.statstrip {
    display: flex;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--card-r);
    padding: 8px 0;
    box-shadow: var(--shadow-card);
}

.statstrip .cell {
    flex: 1 1 0;
    min-width: 180px;
    padding: 12px 22px;
    border-right: 1px solid var(--line);
}

.statstrip .cell:last-child { border-right: none; }
.statstrip .val { font-size: 24px; font-weight: 800; min-height: 30px; }
.statstrip .lbl { color: var(--muted); font-weight: 600; font-size: 13px; }

/* Clickable stat cells drill down to the matching list page */
a.cell { color: inherit; text-decoration: none; transition: background .15s ease; border-radius: 10px; }
a.cell:hover { background: var(--brand-soft); color: inherit; }
a.cell .lbl::after { content: "\f105"; font: var(--fa-font-solid, 900 12px "Font Awesome 6 Free"); margin-left: 6px; opacity: .45; }

/* ===== Multi-select dropdown (replaces native <select multiple>) ===== */
.ms-wrap { position: relative; }
.ms-control {
    width: 100%; text-align: left; cursor: pointer; background-color: var(--surface);
    display: flex; align-items: center; gap: 6px; min-height: 38px; height: auto;
    padding: 4px 10px; background-image: none !important;
}
.ms-control:focus, .ms-control:focus-visible {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 .2rem var(--brand-soft);
}
.ms-control .ms-tags {
    flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: center;
    gap: 4px; min-width: 0; padding: 2px 0;
}
.ms-control .ms-placeholder { color: var(--muted); }
.ms-tag {
    display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
    background: var(--brand-soft); color: var(--brand-d); font-size: 12px; font-weight: 600;
    border-radius: 20px; padding: 2px 4px 2px 10px; line-height: 1.6;
}
.ms-tag-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.ms-tag-remove {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border-radius: 50%; color: var(--brand-d);
    font-size: 9px; cursor: pointer; flex-shrink: 0;
}
.ms-tag-remove:hover { background: rgba(0,0,0,.1); }
.ms-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding-left: 4px; margin-left: auto; }
.ms-clear-btn { display: none; align-items: center; color: var(--muted); font-size: 12px; cursor: pointer; }
.ms-clear-btn:hover { color: var(--down); }
.ms-caret { display: inline-flex; align-items: center; color: var(--muted); font-size: 11px; transition: transform .15s ease; }
.ms-wrap.open .ms-caret { transform: rotate(180deg); color: var(--brand); }
.ms-panel {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 1080;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12); display: none; overflow: hidden;
}
.ms-wrap.open .ms-panel { display: block; }
.ms-search-wrap { padding: 8px; border-bottom: 1px solid var(--line); }
.ms-search {
    width: 100%; border: 1px solid var(--line); border-radius: 8px;
    padding: 6px 10px; font-size: 13px; outline: none;
}
.ms-search:focus { border-color: var(--brand); }
.ms-all, .ms-option {
    display: flex; align-items: center; gap: 8px; padding: 7px 12px;
    cursor: pointer; font-size: 13px; user-select: none;
}
.ms-all { font-weight: 700; border-bottom: 1px solid var(--line); }
.ms-all:hover, .ms-option:hover { background: var(--brand-soft); }
.ms-options { max-height: 220px; overflow-y: auto; }
.ms-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }
.ms-check {
    width: 16px; min-width: 16px; display: inline-flex; justify-content: center;
    color: var(--brand); visibility: hidden; font-size: 12px;
}
.ms-option.selected .ms-check, .ms-all.selected .ms-check { visibility: visible; }
.ms-option.selected .ms-label { font-weight: 600; }

/* ---------- dark stats card ---------- */
.card-dark {
    background: linear-gradient(160deg, #0f1a24, #14212e);
    border: none;
    color: #fff;
}

.card-dark h3 { color: #fff; }

.tile {
    background: #22323f;
    border-radius: 9px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.tile .t { opacity: .7; font-size: 12px; }
.tile b { font-size: 18px; color: #fff; }

/* ---------- stock alerts list ---------- */
.alert-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line-soft);
}

.alert-row:last-child { border-bottom: none; }

.alert-row .ico {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--fill);
    display: grid;
    place-items: center;
    color: var(--ink-tile);
    font-size: 15px;
    flex: 0 0 38px;
}

.alert-row .nm { font-weight: 700; font-size: 13.5px; }
.alert-row .rc { color: var(--muted); font-size: 12px; }

.badge-stock {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-meta);
    white-space: nowrap;
}

.badge-stock .d { width: 7px; height: 7px; border-radius: 50%; }

/* ---------- expired rows ---------- */
.exp-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--danger-soft);
    border: 1px solid var(--danger-line);
    border-left: 3px solid var(--down);
    border-radius: 12px;
    padding: 11px 14px;
    margin-bottom: 10px;
}

.exp-row.warn { background: var(--warning-soft); border-color: var(--warning-line); border-left-color: var(--orange); }

.exp-row .ico {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(231, 65, 58, .12);
    color: var(--down);
    display: grid;
    place-items: center;
}

.exp-row.warn .ico { background: rgba(242, 101, 34, .12); color: var(--orange); }

.exp-row .nm { font-weight: 700; color: var(--ink); }
.exp-row .rc { font-size: 12px; color: var(--muted); }
.exp-row .dt { margin-left: auto; font-weight: 700; font-size: 13px; white-space: nowrap; color: var(--down); }
.exp-row.warn .dt { color: var(--orange); }

/* ---------- invoice summary month picker ---------- */
.inv-summary-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 0 2px;
}
.inv-summary-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.inv-summary-title i { color: var(--brand); }

/* Prev/next single-month stepper + a styled month pill that opens a real
   month/year picker panel (built with the same .dtf-wrap/.dtf-panel pattern
   as the other filters), instead of relying on inconsistent native
   <input type="month"> click-to-open behaviour across browsers. */
.dtf-month-picker { display: inline-flex; align-items: center; gap: 6px; }
.dtf-month-step {
    width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
    border: 1px solid var(--line); background: var(--surface); color: var(--muted);
    display: grid; place-items: center; font-size: 11px; cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}
.dtf-month-step:hover { border-color: var(--brand); color: var(--brand); }
.dtf-month-step:disabled { opacity: .4; cursor: not-allowed; border-color: var(--line); color: var(--muted); }
.dtf-month-label {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
    padding: 5px 12px; font-size: 12px; font-weight: 700; color: var(--ink);
    white-space: nowrap; cursor: pointer; transition: border-color .15s ease;
}
.dtf-month-label i:first-child { color: var(--brand); font-size: 11px; }
.dtf-month-label:hover, .dtf-wrap.open .dtf-month-label { border-color: var(--brand); }
.dtf-wrap.open .dtf-month-label .dtf-caret { transform: rotate(180deg); color: var(--brand); }

.dtf-panel.dtf-month-panel {
    min-width: 230px; max-width: calc(100vw - 32px); padding: 10px;
    left: auto; right: 0;
}
.dtf-month-panel-year {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
    font-weight: 800; font-size: 13px; color: var(--ink);
}
.dtf-month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dtf-month-cell {
    padding: 8px 4px; border-radius: 8px; text-align: center;
    font-size: 12.5px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.dtf-month-cell:hover { background: var(--bg); }
.dtf-month-cell.active { background: var(--brand); color: #fff; }
.dtf-month-cell.disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }

/* ---------- invoice cards ---------- */
.inv-card {
    border-radius: var(--card-r);
    padding: 18px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.inv-card .ic {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 16px;
}

.inv-card .cnt { position: absolute; top: 16px; right: 16px; color: var(--muted); font-size: 12px; font-weight: 600; }
.inv-card .lbl { color: var(--muted); font-weight: 600; margin-top: 16px; }
.inv-card .amt { font-size: 24px; font-weight: 800; margin-top: 2px; }

/* Invoice Summary tints (dashboard). These were inline gradients on the
   elements; as classes they can carry a dark variant, where the same hue
   becomes a wash over the card surface instead of a near-white pastel. */
.inv-card--total { background: linear-gradient(135deg, #eafaf4, #f4fbff); }
.inv-card--paid  { background: linear-gradient(135deg, #eef2ff, #f5f8ff); }
.inv-card--due   { background: linear-gradient(135deg, #fdeeea, #fff6f3); }

html[data-bs-theme="dark"] .inv-card--total { background: linear-gradient(135deg, rgba(15, 172, 156, .17), rgba(15, 172, 156, .05)), var(--surface); }
html[data-bs-theme="dark"] .inv-card--paid  { background: linear-gradient(135deg, rgba(74, 99, 240, .20), rgba(74, 99, 240, .06)), var(--surface); }
html[data-bs-theme="dark"] .inv-card--due   { background: linear-gradient(135deg, rgba(242, 101, 34, .17), rgba(242, 101, 34, .05)), var(--surface); }

/* ---------- dashboard filter bar (date filter + location) ---------- */
.filter-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
/* Bootstrap's .form-select defaults to width:100% (block); the filter bar's
   controls must stay compact/content-sized regardless of that default. */
.filter-bar > * { flex: 0 0 auto; }
.filter-bar select.form-select,
.filter-bar input.form-select {
    width: auto; min-width: 0; padding: 7px 12px; font-size: 12.5px;
    border-color: var(--line); font-weight: 600;
}

/* ---------- date filter dropdown (replaces native <select id="filter_range">) ---------- */
.dtf-wrap { position: relative; flex: 0 0 auto; }
.dtf-control {
    display: inline-flex; align-items: center; gap: 6px; width: auto;
    border: 1px solid var(--line); background: var(--surface); border-radius: 9px;
    padding: 7px 12px; font-weight: 600; font-size: 12.5px; color: var(--ink); cursor: pointer;
    white-space: nowrap;
}
.dtf-control:hover { border-color: var(--brand); }
.dtf-control .dtf-icon { color: var(--brand); font-size: 13px; }
.dtf-control .dtf-caret { font-size: 11px; color: var(--muted); margin-left: 2px; transition: transform .15s ease; }
.dtf-wrap.open .dtf-control { border-color: var(--brand); }
.dtf-wrap.open .dtf-caret { transform: rotate(180deg); color: var(--brand); }
.dtf-panel {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 1080; min-width: 230px;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 16px 36px -12px rgba(20, 33, 46, .25); padding: 6px;
    display: none; max-height: 360px; overflow-y: auto;
}
.dtf-wrap.open .dtf-panel { display: block; }
.dtf-option {
    padding: 9px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
    color: var(--ink); cursor: pointer;
}
.dtf-option:hover { background: var(--bg); }
.dtf-option.active { background: var(--brand); color: #fff; }

/* Native date/month inputs keep their own OS picker, but get the same
   icon + rounded-compact treatment as the rest of the filter bar. */
.dtf-date-wrap { position: relative; flex: 0 0 auto; }
.dtf-date-wrap i {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--brand); font-size: 12px; pointer-events: none;
}
.dtf-date-wrap input {
    padding-left: 28px !important;
}

/* ---------- money collected / paid cards ---------- */
.cf-amount { font-size: 28px; font-weight: 800; margin: 2px 0 16px; min-height: 34px; }
.cf-breakdown { display: flex; flex-direction: column; }
.cf-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.cf-row:last-child { border-bottom: none; }
.cf-row .cf-label { color: var(--muted); font-weight: 600; }
.cf-row .cf-value { font-weight: 700; color: var(--ink); }
.cf-method-wrap { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.cf-subheading {
    font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); margin-bottom: 8px;
}

/* ---------- sale/purchase details popup ---------- */
.dd-section { margin-bottom: 22px; }
.dd-section:last-child { margin-bottom: 0; }
.dd-heading {
    display: flex; align-items: center; gap: 8px;
    font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.dd-heading i { color: var(--brand); font-size: 13px; }
.dd-heading--plain { border-bottom: none; padding-bottom: 0; margin: 4px 0 8px; }
.dd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 20px; }
.dd-grid > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dd-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.dd-value { font-size: 13.5px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }

/* Row hover cue: rows inside Payment Due tables are click-to-view-details */
tr.due-row { cursor: pointer; transition: background .12s ease; }
tr.due-row:hover { background: var(--bg); }

/* ---------- compact section search (Payment Due lists) ---------- */
.dash-search { position: relative; margin-bottom: 12px; }
.dash-search i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--muted); font-size: 12px; pointer-events: none;
}
.dash-search input {
    width: 100%; border: 1px solid var(--line); border-radius: 9px;
    padding: 8px 12px 8px 32px; font-size: 13px; font-family: inherit;
    color: var(--ink); background: var(--input-bg);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.dash-search input::placeholder { color: var(--muted); }
.dash-search input:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 .15rem var(--brand-soft);
}

/* ---------- tables ---------- */
.card2 .table { font-size: 13px; margin-bottom: 0; }
.card2 .table th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; border-bottom-color: var(--line); }
.card2 .table td { vertical-align: middle; }

.pill {
    font-size: 11px; font-weight: 700; border-radius: 20px; padding: 4px 12px 4px 10px;
    display: inline-flex; align-items: center; gap: 6px;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; flex: 0 0 auto; }
.pill-due { background: var(--danger-soft); color: var(--down); }
.pill-partial { background: var(--warning-soft); color: var(--orange); }
.pill-paid { background: var(--success-soft); color: var(--up); }

/* ---------- clickable cards get a subtle lift ---------- */
.inv-card, a.card2 {
    transition: transform .15s ease, box-shadow .15s ease;
}
.inv-card:hover, a.card2:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
}

/* ---------- empty states ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px 12px;
}
.empty-state i {
    font-size: 26px;
    color: var(--muted);
    opacity: .45;
    margin-bottom: 10px;
}
.empty-state .es-title { font-weight: 700; color: var(--ink); font-size: 13.5px; margin-bottom: 2px; }
.empty-state .es-sub { font-size: 12px; color: var(--muted); }

/* ---------- topbar live clock ---------- */
.topbar-time {
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--line);
    color: var(--muted);
    font-weight: 600;
}

/* ---------- scroll-reveal entrance for major dashboard sections ---------- */
.reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .45s ease, transform .45s ease;
}
.reveal.reveal-in { opacity: 1; transform: none; }

/* ---------- skeleton loading shimmer (KPI values, before first fetch) ---------- */
.skel-bar {
    display: inline-block; width: 64px; height: 1em; border-radius: 5px;
    background: linear-gradient(90deg, var(--skel-1) 25%, var(--skel-2) 37%, var(--skel-1) 63%);
    background-size: 400% 100%;
    animation: skel-shimmer 1.4s ease infinite;
    vertical-align: middle;
}
@keyframes skel-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ---------- respect reduced-motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- tabs ---------- */
.mp-tabs { border-bottom: none; margin-bottom: 0; }

.mp-tabs .nav-link {
    border: 1px solid var(--line);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    color: var(--muted);
    font-weight: 700;
    font-size: 13.5px;
    background: var(--fill-2);
    margin-right: 6px;
    padding: 10px 18px;
}

.mp-tabs .nav-link.active { background: var(--surface); color: var(--brand); }

.footer {
    padding: 16px 26px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 13px;
    background: var(--surface);
    margin-top: auto;
}

/* ---------- Mobile / tablet ---------- */
.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 1100px) {
    /* Sidebar becomes a slide-in drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1050;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 0 0 30px rgba(0, 0, 0, .35);
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(15, 25, 35, .5);
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s ease;
    }
    .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

    .sidebar-toggle {
        display: inline-grid;
        place-items: center;
        width: 38px;
        height: 38px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: var(--surface);
        color: var(--ink);
        cursor: pointer;
        flex: 0 0 auto;
    }

    .topbar { padding: 10px 14px; gap: 10px; }
    .topbar h5 { font-size: 16px; }
    .content { padding: 16px 14px; }
    .welcome h1 { font-size: 20px; }
    .hi-bot svg { width: 80px; height: 72px; }

    /* Larger, easier-to-tap nav rows in the mobile drawer */
    .nav-item, .nav-section-toggle { padding-top: 11px; padding-bottom: 11px; font-size: 14px; }
}

@media (max-width: 640px) {
    /* Trim the top bar to essentials on phones */
    .topbar .btn-plain,
    .topbar .icon-btn { display: none; }
    .topbar .avatar + span { display: none; }
    /* Help stays reachable on phones, just collapsed to icon-only */
    .help-btn { padding: 9px 11px; }
    .help-btn .help-btn-label { display: none; }
    .content { padding: 14px 10px; }
    .card2 { border-radius: 14px; }
    .welcome h1 { font-size: 18px; }
    .hi-bot svg { width: 66px; height: 59px; }
    /* Modals get more room */
    .modal-dialog { margin: 8px; }
    /* Tables stay usable: never squash below readable width */
    .table-responsive table { min-width: 620px; }
    .btn-pos, .btn-plain { padding: 8px 14px; font-size: 13px; }
}

/* ================================================================
   GLOBAL FORM / COMPONENT POLISH
   Every custom component above (.card2, .pill, .btn-plain, .ms-*,
   .dtf-*) was already carefully designed - but Bootstrap's own
   .form-control/.form-select/.modal/.alert/.pagination/.dropdown-menu
   never got matching rules anywhere in this file, so a plain
   <input class="form-control"> or <select class="form-select">
   (used on nearly every page in every module) fell back to raw,
   unbranded Bootstrap grey next to those polished components. This
   section brings the whole app up to one consistent standard in a
   single place, so every existing page benefits without per-page
   changes - and fixes the specific mobile issues called out in the
   global UI/UX pass (tiny/cramped controls, modals overflowing the
   viewport, un-styled alerts/pagination/dropdowns).
   ================================================================ */

/* ---------- form controls ---------- */
.form-control, .form-select {
    border-color: var(--input-border);
    background-color: var(--input-bg);
    border-radius: 9px;
    font-size: 13.5px;
    color: var(--ink);
    padding: 8px 12px;
    min-height: 40px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control::placeholder { color: var(--placeholder); }
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .18rem var(--brand-soft);
}
.form-control:disabled, .form-select:disabled, .form-control[readonly] {
    background: var(--bg); color: var(--muted); opacity: 1;
}
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--down); }
.form-control.is-invalid:focus, .form-select.is-invalid:focus {
    box-shadow: 0 0 0 .18rem rgba(231, 65, 58, .16);
}
.invalid-feedback { font-size: 12px; }
textarea.form-control { min-height: 84px; padding-top: 9px; }
.form-control-sm, .form-select-sm { border-radius: 8px; font-size: 12.5px; padding: 6px 10px; min-height: 33px; }
.form-control-lg, .form-select-lg { border-radius: 10px; min-height: 46px; }
.form-label { font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.form-text { font-size: 12px; color: var(--muted); }
.form-check-input { width: 17px; height: 17px; margin-top: 2px; border-color: var(--input-border-2); cursor: pointer; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 .15rem var(--brand-soft); }
.form-check-label { cursor: pointer; }
.input-group-text { background: var(--input-addon-bg); border-color: var(--input-border); color: var(--muted); font-size: 13px; }
input[type="file"].form-control { padding: 7px 12px; }
/* Native date/time pickers - same rounded/branded frame as every other
   field. The OS-native calendar popup itself can't be restyled
   cross-browser, but that's the picker UI, not the field that opens it. */
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] { min-height: 40px; }

/* ---------- buttons ---------- */
/* .btn-pos / .btn-plain (this app's own primary/secondary) are already
   fully styled above; this fills in the plain Bootstrap semantic variants
   used here and there (outline-secondary close/cancel, btn-danger
   confirmations) so they share the same radius/weight/height instead of
   looking like a different app bolted on. */
.btn { border-radius: 9px; font-weight: 600; font-size: 13.5px; padding: 8px 16px; }
.btn-sm { border-radius: 8px; font-size: 12.5px; padding: 6px 12px; }
.btn-lg { border-radius: 10px; padding: 10px 20px; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-outline-secondary { border-color: var(--input-border); color: var(--ink); }
.btn-outline-secondary:hover { background: var(--surface-hover); border-color: var(--input-border-2); color: var(--ink); }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn-danger { background: var(--down); border-color: var(--down); }
.btn-success { background: var(--up); border-color: var(--up); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
/* Opt-in loading state - toggle a `.btn-loading` class from a form's own
   submit handler; label stays laid out (no shift), a small spinner
   overlays it. Infrastructure only - not wired into existing forms here,
   since that would mean touching every submit handler in the app. */
.btn-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn-loading::after {
    content: ""; position: absolute; top: 50%; left: 50%; width: 15px; height: 15px;
    margin: -7.5px 0 0 -7.5px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff;
    animation: btn-spin .6s linear infinite;
}
.btn-plain.btn-loading::after, .btn-outline-secondary.btn-loading::after { border-color: var(--line); border-top-color: var(--brand); }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ---------- dropdown menus (Actions buttons, filters, etc.) ---------- */
.dropdown-menu { background: var(--surface-2); border-color: var(--line); border-radius: 12px; box-shadow: var(--shadow-raised); padding: 6px; }
.dropdown-item { border-radius: 8px; font-size: 13px; padding: 8px 12px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-hover); }
.dropdown-item.active, .dropdown-item:active { background: var(--brand-soft); color: var(--brand-d); }
.dropdown-divider { border-color: var(--line); margin: 6px 4px; }

/* ---------- modals ---------- */
.modal-content { background: var(--surface-3); border-radius: var(--card-r); border-color: var(--line); overflow: hidden; }
.modal-header, .modal-footer { border-color: var(--line); padding: 16px 20px; }
.modal-header .modal-title { font-weight: 800; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-footer { gap: 8px; }
.btn-close:focus { box-shadow: 0 0 0 .15rem var(--brand-soft); }

/* ---------- alerts ---------- */
.alert { border-radius: 12px; font-size: 13px; border-width: 1px; padding: 12px 16px; }
.alert-danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger-ink); }
.alert-success { background: var(--success-soft); border-color: var(--success-line); color: var(--success-ink); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-line); color: var(--warning-ink); }
.alert-info { background: var(--brand-soft); border-color: rgba(15, 172, 156, .25); color: var(--brand-d); }

/* ---------- pagination ---------- */
.pagination { gap: 4px; flex-wrap: wrap; }
.page-link { border-color: var(--line); color: var(--ink); border-radius: 8px !important; font-size: 13px; font-weight: 600; padding: 6px 12px; margin: 0 !important; }
.page-link:hover { background: var(--surface-hover); color: var(--ink); }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
.page-item.disabled .page-link { color: var(--muted); background: var(--surface); }

/* ---------- badges ---------- */
.badge { font-weight: 700; border-radius: 7px; padding: 4px 8px; }

/* ---------- plain tables outside .card2 ---------- */
.table { font-size: 13px; }
.table th { background: var(--table-head); color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table td, .table th { padding: 10px 12px; vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--surface-hover); }

/* ---------- global overflow safety net ---------- */
/* An oversized upload (business logo, attachment preview, etc.) is the most
   common accidental source of page-level horizontal scroll - contain it at
   the source rather than only patching symptoms per-page. */
img { max-width: 100%; height: auto; }
pre, code { white-space: pre-wrap; word-break: break-word; }

/* ---------- mobile: comfortable touch targets + no accidental zoom ---------- */
@media (max-width: 640px) {
    /* Modals: near-full-width, comfortable margins, body scrolls
       internally instead of pushing the header/footer off-screen. */
    .modal-dialog { margin: 10px; max-width: calc(100vw - 20px); }
    .modal-body { max-height: 70vh; overflow-y: auto; padding: 16px; }
    .modal-header, .modal-footer { padding: 14px 16px; }

    /* iOS Safari auto-zooms the whole page when a focused text input's
       font-size is under 16px - sizing up here avoids that jarring zoom-in
       on every tap into a search/filter field, not just making text bigger. */
    .form-control, .form-select, .form-control-sm, .form-select-sm { font-size: 16px; min-height: 42px; }
    .btn, .btn-plain, .btn-pos { min-height: 40px; }
    .btn-sm { min-height: 34px; }
    .form-check-input { width: 19px; height: 19px; }
    .dropdown-item { padding: 10px 14px; }
}

/*  ---------- searchable select (js/searchable-select.js) ----------
    One shared control that upgrades long native <select> elements in place.
    Deliberately styled to match .form-select exactly in its resting state, so
    a page with a mix of searchable and plain dropdowns still looks uniform -
    the only visible difference is the search box that appears once it opens.

    Every colour is a token, so this follows light/dark with no dark-specific
    rules of its own. */
.fsel-wrap { position: relative; }

/* Visually hidden, but still focusable so the browser can report `required`
   validation against it rather than refusing to focus a display:none field. */
.fsel-native {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: 0; border: 0;
    opacity: 0; pointer-events: none;
    clip-path: inset(50%);
}

.fsel {
    display: flex; align-items: center; gap: 8px;
    width: 100%; min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    border-radius: 9px;
    font-size: 13.5px;
    color: var(--ink);
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.fsel-sm { min-height: 33px; padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.fsel:hover { border-color: var(--input-border-2); }
.fsel:focus-visible, .fsel.is-open {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 .18rem var(--brand-soft);
}
.fsel.is-invalid { border-color: var(--down); }

.fsel-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsel-value.is-placeholder { color: var(--placeholder); }
.fsel-caret { flex: 0 0 auto; font-size: 11px; color: var(--muted); transition: transform .15s ease; }
.fsel.is-open .fsel-caret { transform: rotate(180deg); color: var(--brand); }

/* data-search-inline: the field is a search bar - type straight into it */
.fsel-inline { cursor: text; }
.fsel-inline:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 .18rem var(--brand-soft);
}
.fsel-inline-icon { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.fsel-inline-input {
    flex: 1 1 auto; min-width: 0; border: 0; outline: 0; padding: 0;
    background: transparent; color: var(--ink); font: inherit;
    text-overflow: ellipsis;
}
.fsel-inline-input::placeholder { color: var(--placeholder); }
.fsel-inline .fsel-caret { cursor: pointer; }

.fsel-panel {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1080;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-raised);
    padding: 8px;
    min-width: 220px;
}
.fsel-panel[hidden] { display: none; }

.fsel-search-wrap { position: relative; }
.fsel-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }
.fsel-search {
    width: 100%;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--ink);
    border-radius: 7px;
    padding: 7px 10px 7px 30px;
    font-size: 13px;
}
.fsel-search::placeholder { color: var(--placeholder); }
.fsel-search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.fsel-list { max-height: 260px; overflow-y: auto; margin-top: 6px; }
.fsel-item {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fsel-item:hover { background: var(--surface-hover); }
.fsel-item.is-active { background: var(--tint-sel); box-shadow: inset 3px 0 0 var(--brand); }
.fsel-item.is-selected { color: var(--brand); font-weight: 700; }
.fsel-empty { padding: 12px 4px; color: var(--muted); font-size: 12px; text-align: center; }
.fsel-muted { color: var(--muted); }

/*  ============================================================
    DARK THEME - COMPONENT POLISH
    ============================================================
    Everything above already paints from tokens, so the palette swap alone
    carries most of the theme. What lives here is the handful of things a
    token cannot express: the accent edge on the active nav item, the sheen
    that keeps a card from reading as a flat rectangle, the direction a row
    moves on hover.

    All of it is scoped to html[data-bs-theme="dark"], so LIGHT MODE CANNOT
    BE AFFECTED by anything in this block - and it lives in the shared
    stylesheet rather than in individual pages, so every screen that uses
    these components gets it for free.

    Selectors are written flat rather than nested, so no CSS-nesting support
    is required of the browser.

    Inside `@media screen` for the same reason as the token block: none of
    this should reach paper.                                              */
@media screen {

    /* ---------- sidebar: the app's frame ----------
       The sidebar is dark in BOTH themes, so these are deliberate dark-only
       refinements rather than fixes. The active item swaps a solid brand
       block for a brand-tinted wash with a hard accent edge and a soft halo -
       it reads as lit from within rather than painted over. */
    html[data-bs-theme="dark"] .sidebar { border-right: 1px solid var(--line); }

    html[data-bs-theme="dark"] .nav-item:hover,
    html[data-bs-theme="dark"] .nav-section-toggle:hover {
        background: rgba(255, 255, 255, .055);
        color: #fff;
    }

    html[data-bs-theme="dark"] .nav-item.active {
        background: linear-gradient(90deg, rgba(15, 172, 156, .26), rgba(15, 172, 156, .06) 72%, transparent);
        color: #fff;
        box-shadow: inset 2px 0 0 var(--brand), var(--glow-accent);
    }
    html[data-bs-theme="dark"] .nav-item.active i:first-child { color: var(--brand); }

    /* ---------- topbar ----------
       A hairline of light along the top edge plus a soft drop below it, so
       the bar sits ON the page rather than being a differently-coloured
       piece of it. */
    html[data-bs-theme="dark"] .topbar {
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 6px 20px -16px rgba(0, 0, 0, .9);
    }

    /* ---------- cards ----------
       A barely-there sheen down the first 140px. It is what stops a dark card
       from looking like a hole cut in the page; at 2.2% it is felt more than
       seen, which is the intent. */
    html[data-bs-theme="dark"] .card2,
    html[data-bs-theme="dark"] .statstrip {
        background: linear-gradient(180deg, rgba(255, 255, 255, .022), rgba(255, 255, 255, 0) 140px), var(--surface);
    }
    html[data-bs-theme="dark"] .card2:hover { border-color: var(--line-strong); }

    /* ---------- tables ----------
       Bootstrap 5.3 drives table colours through its own variables, so they
       are set here rather than fought with overrides. Rows sit on the card
       (transparent) and only the header and hover state carry a fill. */
    html[data-bs-theme="dark"] .table {
        --bs-table-bg: transparent;
        --bs-table-color: var(--ink);
        --bs-table-border-color: var(--line);
        --bs-table-striped-bg: rgba(255, 255, 255, .022);
        --bs-table-striped-color: var(--ink);
        --bs-table-hover-bg: var(--surface-hover);
        --bs-table-hover-color: var(--ink);
    }
    html[data-bs-theme="dark"] .table thead th {
        border-bottom-color: var(--line-strong);
    }

    /* ---------- elevated surfaces ----------
       A firmer border and a deeper shadow, so a menu or a modal separates
       from the page by elevation rather than by being brighter. */
    html[data-bs-theme="dark"] .dropdown-menu,
    html[data-bs-theme="dark"] .help-menu {
        border-color: var(--line-strong);
        box-shadow: var(--shadow-raised);
    }
    html[data-bs-theme="dark"] .modal-content {
        border-color: var(--line-strong);
        box-shadow: var(--shadow-raised);
    }
    html[data-bs-theme="dark"] .modal-backdrop.show { background: var(--overlay); opacity: 1; }
    html[data-bs-theme="dark"] .modal-header,
    html[data-bs-theme="dark"] .modal-footer { border-color: var(--line); }

    /* ---------- inputs ----------
       Recessed surface, a border that firms up under the cursor, and an
       accent ring on focus. The ring is the one place a glow is always
       correct: it has to be unmissable for keyboard users. */
    html[data-bs-theme="dark"] .form-control:hover:not(:focus):not(:disabled):not([readonly]),
    html[data-bs-theme="dark"] .form-select:hover:not(:focus):not(:disabled) {
        border-color: var(--line-strong);
    }
    html[data-bs-theme="dark"] .form-control:focus,
    html[data-bs-theme="dark"] .form-select:focus {
        background-color: var(--surface);
        box-shadow: 0 0 0 3px rgba(15, 172, 156, .25);
    }
    html[data-bs-theme="dark"] .form-control:disabled,
    html[data-bs-theme="dark"] .form-select:disabled,
    html[data-bs-theme="dark"] .form-control[readonly] {
        background: var(--panel);
        color: var(--muted);
        border-color: var(--line);
    }

    /* ---------- buttons ----------
       The failure mode on dark is a button dissolving into the page, so the
       quiet variants get a real surface and a real border. */
    html[data-bs-theme="dark"] .btn-plain,
    html[data-bs-theme="dark"] .icon-btn,
    html[data-bs-theme="dark"] .round-btn {
        background: var(--surface-2);
        border-color: var(--line-strong);
    }
    html[data-bs-theme="dark"] .btn-plain:hover,
    html[data-bs-theme="dark"] .icon-btn:hover {
        background: var(--surface-hover);
        border-color: var(--brand);
    }
    html[data-bs-theme="dark"] .btn-outline-secondary { border-color: var(--line-strong); }
    html[data-bs-theme="dark"] .btn-primary:hover { box-shadow: var(--glow-accent); }
    html[data-bs-theme="dark"] .btn:disabled,
    html[data-bs-theme="dark"] .btn.disabled { opacity: .45; }

    /* Keyboard focus stays obvious everywhere, not just on inputs. */
    html[data-bs-theme="dark"] .btn:focus-visible,
    html[data-bs-theme="dark"] .btn-plain:focus-visible,
    html[data-bs-theme="dark"] .icon-btn:focus-visible,
    html[data-bs-theme="dark"] .dropdown-item:focus-visible {
        outline: 2px solid var(--brand);
        outline-offset: 2px;
    }

    /* ---------- tabs ----------
       The active tab is marked by an accent edge, not by being the brightest
       block on screen. */
    html[data-bs-theme="dark"] .mp-tabs .nav-link { border-color: var(--line); }
    html[data-bs-theme="dark"] .mp-tabs .nav-link:hover { color: var(--ink); background: var(--surface-hover); }
    html[data-bs-theme="dark"] .mp-tabs .nav-link.active {
        background: var(--surface);
        box-shadow: inset 0 2px 0 var(--brand);
    }

    /* ---------- pagination ---------- */
    html[data-bs-theme="dark"] .page-link { background: var(--surface-2); border-color: var(--line-strong); }
    html[data-bs-theme="dark"] .page-item.disabled .page-link { background: var(--panel); border-color: var(--line); }

    /* ---------- alerts ----------
       The washes come from tokens already; this just firms the edge so a
       tinted panel still reads as a panel. */
    html[data-bs-theme="dark"] .alert { border-width: 1px; }
    html[data-bs-theme="dark"] .alert-info { border-color: rgba(15, 172, 156, .34); color: var(--brand); }

    /* ---------- toasts ---------- */
    html[data-bs-theme="dark"] .toast {
        background: var(--surface-3);
        border-color: var(--line-strong);
        box-shadow: var(--shadow-raised);
        color: var(--ink);
    }
    html[data-bs-theme="dark"] .toast-header {
        background: var(--surface-2);
        border-bottom-color: var(--line);
        color: var(--ink);
    }

    /* ---------- scrollbars ----------
       Present enough to grab, quiet enough to ignore. */
    html[data-bs-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }
    html[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

    /* ---------- Bootstrap utilities that do NOT flip ----------
       Bootstrap 5.3 re-points most of its colour utilities under
       data-bs-theme, but a handful are pinned to a literal light value:
       .text-dark stays near-black, .bg-white stays white, and so on. Used on
       a dark surface they produce exactly the "invisible text" failure -
       which is what `class="fw-bold text-dark"` on the POS cart product name
       was doing.

       Re-pointed here, centrally, rather than hunting the class down page by
       page: any view that uses one of these now works in both themes, today
       and in future. Light is untouched - Bootstrap's own values still apply
       there. !important is required only because the utilities themselves
       carry it. */
    html[data-bs-theme="dark"] .text-dark,
    html[data-bs-theme="dark"] .text-black { color: var(--ink) !important; }
    html[data-bs-theme="dark"] .link-dark { color: var(--ink) !important; }
    html[data-bs-theme="dark"] .bg-white { background-color: var(--surface) !important; }
    html[data-bs-theme="dark"] .bg-light { background-color: var(--fill) !important; }
    html[data-bs-theme="dark"] .border-white,
    html[data-bs-theme="dark"] .border-light { border-color: var(--line) !important; }
    html[data-bs-theme="dark"] .table-light > * > * {
        background-color: var(--table-head) !important;
        color: var(--ink) !important;
    }

    /* Native <option> lists are painted by the OS. Bootstrap sets
       color-scheme: dark on the root, so the popup is dark - which makes a
       hard-coded dark option colour invisible. */
    html[data-bs-theme="dark"] select option { color: var(--ink); background: var(--surface-2); }

    /* Help menu: the ticket accent is the one icon colour mixed for white. */
    html[data-bs-theme="dark"] .help-menu-item .hm-ic.call { color: #35d9c7; }

    /* ---------- DataTables ----------
       The bs5 integration inherits Bootstrap's own dark variables; only its
       own wrapper chrome needs pointing at our tokens. (Select2, TomSelect,
       flatpickr and SweetAlert are NOT used anywhere in this app - verified
       across every view - so there is nothing to theme for them.) */
    html[data-bs-theme="dark"] .dataTables_wrapper .dataTables_info,
    html[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length,
    html[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter { color: var(--muted); }
    html[data-bs-theme="dark"] table.dataTable thead th.sorting:before,
    html[data-bs-theme="dark"] table.dataTable thead th.sorting:after { color: var(--muted); }
}

/*  Printing while the screen is dark
    --------------------------------
    The token block above is scoped to `screen`, so this stylesheet's own
    colours already revert to the light `:root` set on paper. Bootstrap's
    dark variables are not scoped that way, though, so they are reset here -
    otherwise a page printed in dark mode comes out as light text on white.

    This matters beyond convenience: receipts, invoices, labels and reports
    are customer-facing documents and must always print on white. The
    standalone print views (sell/receipt, labels/*, the *_print views) never
    load this stylesheet or the theme attribute at all, so they are light by
    construction; this covers the in-app pages that get sent to a printer. */
@media print {
    html[data-bs-theme="dark"] {
        color-scheme: light;
        --bs-body-bg: #fff;
        --bs-body-color: #212529;
        --bs-emphasis-color: #000;
        --bs-secondary-bg: #e9ecef;
        --bs-secondary-color: rgba(33, 37, 41, .75);
        --bs-tertiary-bg: #f8f9fa;
        --bs-border-color: #dee2e6;
    }
    html[data-bs-theme="dark"] body { background: #fff; color: var(--ink); }

    /* The switch itself has no meaning on paper. Deliberately nothing else
       is hidden here - what a page prints otherwise is unchanged. */
    .theme-toggle { display: none !important; }
}

/* ---------- Export toolbars: column menus always open downward ----------
   DataTables ("Column visibility") positions its menu with inline styles and
   flips it ABOVE the button whenever the table is short, where the scrolling
   wrappers (.table-responsive / .dataTables_wrapper) then cut it off.
   It is anchored under its button instead (see "column menus open downward"
   in layouts/app), escapes those wrappers while it is open, and scrolls
   inside the menu when the column list is long.
   Applies to every page that uses the DataTables buttons. */
div.dt-button-collection {
    /* top is set just under the button by the script in layouts/app */
    bottom: auto !important;
    margin-top: 0 !important;
    max-height: min(60vh, 420px);
    overflow-y: auto;
    z-index: 1060;
}
.table-responsive:has(div.dt-button-collection),
.dataTables_wrapper:has(div.dt-button-collection) { overflow: visible !important; }

/* Shared report toolbar "Columns" menu (report._table_toolbar): same rule -
   below the button, never flipped above it, long lists scroll. */
[id$="_cols"].dropdown-menu { max-height: min(60vh, 420px); overflow-y: auto; }
