/* ============================================================
   TrivexaLite — professional orange theme
   ============================================================ */
:root {
    --tx-orange:       #F57C00;
    --tx-orange-600:   #EF6C00;
    --tx-orange-700:   #E65100;
    --tx-orange-300:   #FFB74D;
    --tx-orange-50:    #FFF4E6;
    --tx-ink:          #1c2330;
    --tx-ink-2:        #262f3f;
    --tx-ink-3:        #313b4d;
    --tx-muted:        #8a93a6;
    --tx-bg:           #f5f6f8;
    --tx-grad:         linear-gradient(135deg, #FF9D2E 0%, #F57C00 45%, #E65100 100%);
    --tx-shadow-xs:    0 1px 2px rgba(16,24,40,.05);
    --tx-shadow:       0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
    --tx-shadow-md:    0 8px 20px rgba(16,24,40,.08);
    --tx-shadow-lg:    0 12px 30px rgba(16,24,40,.12);
    --tx-ease:         cubic-bezier(.2,.8,.2,1);
}

body { background: var(--tx-bg); color: #222; font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; }

/* ---- Typography scale ---- */
h1, .h1 { font-size: 2rem;    font-weight: 700; letter-spacing: -.01em; }
h2, .h2 { font-size: 1.6rem;  font-weight: 700; letter-spacing: -.01em; }
h3, .h3 { font-size: 1.3rem;  font-weight: 700; }
h4, .h4 { font-size: 1.1rem;  font-weight: 600; }
h5, .h5 { font-size: 1rem;    font-weight: 600; }
h6, .h6 { font-size: .82rem;  font-weight: 700; letter-spacing: .02em; }
.text-eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tx-muted); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---- Bootstrap primary → orange ---- */
.btn-primary {
    --bs-btn-bg: var(--tx-orange); --bs-btn-border-color: var(--tx-orange);
    --bs-btn-hover-bg: var(--tx-orange-600); --bs-btn-hover-border-color: var(--tx-orange-600);
    --bs-btn-active-bg: var(--tx-orange-700); --bs-btn-active-border-color: var(--tx-orange-700);
    --bs-btn-disabled-bg: var(--tx-orange-300); --bs-btn-disabled-border-color: var(--tx-orange-300);
    box-shadow: 0 6px 14px rgba(245,124,0,.30); transition: transform .12s ease, box-shadow .12s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(245,124,0,.36); }
.btn-primary:active { transform: translateY(0); }
.btn-outline-primary {
    --bs-btn-color: var(--tx-orange-700); --bs-btn-border-color: var(--tx-orange);
    --bs-btn-hover-bg: var(--tx-orange); --bs-btn-hover-border-color: var(--tx-orange);
    --bs-btn-active-bg: var(--tx-orange-700); --bs-btn-active-border-color: var(--tx-orange-700);
}
.text-primary { color: var(--tx-orange-700) !important; }
.bg-primary  { background-color: var(--tx-orange) !important; }
.badge.bg-primary { background-color: var(--tx-orange) !important; }
a { color: var(--tx-orange-700); text-decoration: none; }
a:hover { color: var(--tx-orange-600); }
.form-control:focus, .form-select:focus {
    border-color: var(--tx-orange-300);
    box-shadow: 0 0 0 .2rem rgba(245,124,0,.18);
}
.form-check-input:checked { background-color: var(--tx-orange); border-color: var(--tx-orange); }

/* ---- Cards ---- */
.card { border: 1px solid rgba(16,24,40,.06); border-radius: .8rem; box-shadow: var(--tx-shadow); }
.card.shadow-sm { box-shadow: var(--tx-shadow) !important; }
a.card { transition: transform .15s ease, box-shadow .15s ease; }
a.card:hover { transform: translateY(-3px); box-shadow: var(--tx-shadow-lg); }

/* ============================================================
   App shell
   ============================================================ */
#app-wrapper { background: var(--tx-bg); }

#sidebar {
    background: linear-gradient(180deg, var(--tx-ink) 0%, var(--tx-ink-2) 100%);
    box-shadow: 2px 0 12px rgba(16,24,40,.10);
    position: relative; z-index: 9;
    width: 254px; min-height: 100vh; flex: 0 0 254px;
    display: flex; flex-direction: column;
    transition: transform .25s ease, width .2s ease, flex-basis .2s ease;
}
/* align-self:flex-start stops the row's default stretch (driven by #sidebar's own
   min-height:100vh) from forcing this column to full viewport height too -- without it,
   the header+main+footer stack would be padded out with blank space below the footer
   on any page shorter than one viewport. The sidebar still looks full-height on its own. */
#app-main { min-width: 0; align-self: flex-start; }

.tx-sidebar-scroll { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }

.tx-burger, .tx-sidebar-close, .tx-sidebar-collapse-toggle {
    background: transparent; border: 0; font-size: 1.2rem; line-height: 1;
    padding: .4rem .55rem; border-radius: 8px; display: inline-flex; align-items: center;
    transition: background .12s ease, color .12s ease;
}
.tx-burger { color: var(--tx-ink-2); margin-inline-end: .5rem; }
.tx-burger:hover { background: var(--tx-orange-50); color: var(--tx-orange-700); }
.tx-sidebar-close { color: rgba(255,255,255,.65); margin-inline-start: auto; }
.tx-sidebar-close:hover { color: #fff; background: rgba(255,255,255,.08); }
.tx-sidebar-collapse-toggle { color: rgba(255,255,255,.55); margin-inline-start: auto; flex: none; }
.tx-sidebar-collapse-toggle:hover { color: #fff; background: rgba(255,255,255,.08); }

.tx-sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(16,24,40,.5);
    backdrop-filter: blur(1px); z-index: 8; opacity: 0; transition: opacity .2s ease;
}

@media (max-width: 991.98px) {
    #sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(-100%); }
    [dir="rtl"] #sidebar { transform: translateX(100%); }
    #sidebar.tx-open { transform: translateX(0); }
    body.tx-sidebar-open { overflow: hidden; }
    body.tx-sidebar-open .tx-sidebar-backdrop { display: block; opacity: 1; }
}

/* Desktop icon-rail collapse — power-user toggle, persisted via localStorage. */
@media (min-width: 992px) {
    #app-wrapper.tx-sidebar-collapsed #sidebar { width: 72px; flex-basis: 72px; }
    #app-wrapper.tx-sidebar-collapsed .tx-brand .tx-name,
    #app-wrapper.tx-sidebar-collapsed .tx-nav-text,
    #app-wrapper.tx-sidebar-collapsed .tx-nav-group-label,
    #app-wrapper.tx-sidebar-collapsed .tx-nav-caret,
    #app-wrapper.tx-sidebar-collapsed .tx-sidebar-user-info { display: none; }
    #app-wrapper.tx-sidebar-collapsed .tx-nav-group-list { display: block !important; }
    #app-wrapper.tx-sidebar-collapsed .tx-brand { justify-content: center; padding-inline: .5rem; }
    #app-wrapper.tx-sidebar-collapsed .tx-sidebar-collapse-toggle { margin-inline-start: 0; }
    #app-wrapper.tx-sidebar-collapsed #sidebar .nav-link { justify-content: center; margin-inline: 6px; padding-inline: .5rem; }
    #app-wrapper.tx-sidebar-collapsed #sidebar .nav-link i { margin-inline-end: 0 !important; }
    #app-wrapper.tx-sidebar-collapsed .tx-sidebar-user { justify-content: center; }
}

/* Sidebar quick-filter (Ctrl+K / "/") */
.tx-nav-filter { position: relative; padding: .65rem .9rem .15rem; flex: none; }
.tx-nav-filter > i {
    position: absolute; inset-inline-start: 1.55rem; top: calc(50% + .2rem); transform: translateY(-50%);
    color: #7b8499; font-size: .78rem; pointer-events: none;
}
.tx-nav-filter .form-control {
    background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.10);
    color: #e8ebf1; border-radius: 8px; padding-inline-start: 30px; font-size: .82rem;
}
.tx-nav-filter .form-control::placeholder { color: #7b8499; }
.tx-nav-filter .form-control:focus {
    background: rgba(255,255,255,.10); border-color: var(--tx-orange-300);
    box-shadow: 0 0 0 .15rem rgba(245,124,0,.25); color: #fff;
}
.tx-nav-filter-empty { color: #7b8499; font-size: .78rem; padding: .5rem 1.2rem; flex: none; }
/* While filtering, every group opens so matches inside collapsed groups are visible.
   Bootstrap's Collapse state is untouched — clearing the filter restores it. */
#sidebar.tx-filtering .tx-nav-group-list { display: block !important; }
#app-wrapper.tx-sidebar-collapsed .tx-nav-filter,
#app-wrapper.tx-sidebar-collapsed .tx-nav-filter-empty { display: none; }

/* Sidebar scrollbar — thin and dark so it disappears into the ink background */
.tx-sidebar-scroll { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.tx-sidebar-scroll::-webkit-scrollbar { width: 6px; }
.tx-sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.tx-sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }
.tx-sidebar-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.30); }

.tx-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.06);
}
.tx-brand .tx-logo {
    width: 34px; height: 34px; border-radius: 9px; background: var(--tx-grad);
    display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.05rem;
    box-shadow: 0 4px 12px rgba(245,124,0,.45); flex: none;
}
.tx-brand .tx-name { color: #fff; font-weight: 700; letter-spacing: .3px; }
.tx-brand .tx-name span { color: var(--tx-orange-300); }

/* Collapsible module groups */
.tx-nav-group-btn {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
    background: transparent; border: 0; color: #7b8499; font-weight: 600;
    text-transform: uppercase; letter-spacing: .8px; font-size: .74rem;
    padding: .7rem 1rem .3rem;
}
.tx-nav-group-btn:hover { color: #b7bfcf; }
.tx-nav-caret { font-size: .7rem; transition: transform .18s ease; }
.tx-nav-group-btn[aria-expanded="true"] .tx-nav-caret { transform: rotate(180deg); }
.tx-nav-group-list { list-style: none; margin: 0; padding: 0; }

/* Nested sub-group (e.g. Accounting > Accounts / Transactions / Reports) — one level in,
   normal case (not uppercase), so it reads as a sibling category rather than another module. */
.tx-nav-subgroup-btn {
    padding-inline-start: 1.6rem; text-transform: none; letter-spacing: normal;
    font-size: .82rem; color: #c4cbd8; padding-block: .5rem;
}
.tx-nav-subgroup-btn:hover { color: #fff; background: rgba(255,255,255,.06); border-radius: 8px; margin-inline: 8px; width: calc(100% - 16px); }
.tx-nav-subgroup .tx-nav-group-list .nav-link { padding-inline-start: 2.4rem; }

#sidebar .nav-link {
    color: #c4cbd8; border-radius: 8px; margin: 2px 10px; padding: .55rem .8rem;
    position: relative; transition: background .15s ease, color .15s ease, padding .15s ease;
    display: flex; align-items: center; white-space: nowrap; overflow: hidden;
}
#sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
#sidebar .nav-link.active, #sidebar .nav-link.active:hover {
    background: rgba(245,124,0,.16); color: #fff;
}
#sidebar .nav-link.active::before {
    content: ""; position: absolute; inset-inline-start: -10px; top: 8px; bottom: 8px;
    width: 4px; border-radius: 4px; background: var(--tx-grad);
}
#sidebar .nav-link i { width: 20px; text-align: center; flex: none; }
#sidebar .nav-link:focus-visible, .tx-nav-group-btn:focus-visible,
.tx-burger:focus-visible, .tx-sidebar-close:focus-visible, .tx-sidebar-collapse-toggle:focus-visible {
    outline: 2px solid var(--tx-orange-300); outline-offset: 2px;
}

/* Sidebar user card, pinned to the bottom */
.tx-sidebar-user {
    display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem;
    border-top: 1px solid rgba(255,255,255,.08); flex: none;
}
.tx-sidebar-user-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--tx-grad);
    color: #fff; font-weight: 700; font-size: .85rem; display: grid; place-items: center; flex: none;
}
.tx-sidebar-user-info { min-width: 0; }
.tx-sidebar-user-name { color: #fff; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sidebar-user-company { color: #8a93a6; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Skip link — hidden until keyboard-focused (WCAG 2.4.1 bypass blocks) */
.tx-skip-link {
    position: absolute; inset-inline-start: -9999px; top: 1rem; z-index: 1080;
    background: var(--tx-ink); color: #fff; padding: .6rem 1rem; border-radius: .5rem;
    box-shadow: var(--tx-shadow-lg);
}
.tx-skip-link:focus { inset-inline-start: 1rem; }

/* topbar */
header.navbar {
    background: #fff !important; box-shadow: 0 1px 0 rgba(16,24,40,.06), 0 2px 10px rgba(16,24,40,.04);
    min-height: 60px; position: sticky; top: 0; z-index: 4;
}
header.navbar .navbar-brand i { color: var(--tx-orange); }
header .dropdown-item.active { background: var(--tx-orange); }
header .dropdown-menu { border: 0; box-shadow: var(--tx-shadow-lg); border-radius: .7rem; }
footer.footer { background: #fff; }

/* Topbar icon buttons (fullscreen, ...) — same treatment as the burger */
.tx-topbar-btn {
    background: transparent; border: 0; color: var(--tx-ink-3); font-size: 1.05rem;
    line-height: 1; padding: .45rem .6rem; border-radius: 8px; display: inline-flex; align-items: center;
    transition: background .12s ease, color .12s ease;
}
.tx-topbar-btn:hover { background: var(--tx-orange-50); color: var(--tx-orange-700); }
.tx-topbar-btn:focus-visible { outline: 2px solid var(--tx-orange-300); outline-offset: 2px; }

/* Topbar user chip */
.tx-user-chip { display: inline-flex; align-items: center; gap: .45rem; }
.tx-user-chip .tx-avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--tx-grad);
    color: #fff; font-weight: 700; font-size: .8rem; display: grid; place-items: center; flex: none;
    box-shadow: 0 3px 8px rgba(245,124,0,.35);
}
header .dropdown-header { padding-block: .55rem .35rem; }

/* page headings get a subtle orange accent bar */
.tx-main > h3:first-child, .tx-main > .d-flex:first-child > h3 {
    position: relative; padding-inline-start: .8rem;
}
.tx-main > h3:first-child::before, .tx-main > .d-flex:first-child > h3::before {
    content: ""; position: absolute; inset-inline-start: 0; top: .15em; bottom: .15em;
    width: 4px; border-radius: 4px; background: var(--tx-grad);
}

/* NOTE: .tx-main deliberately has no animation/transform/opacity-transition.
   Any of those force it into its own stacking context, which traps every
   position:fixed descendant (Bootstrap modals) below the sticky header's
   z-index instead of the viewport — modal renders "behind" the header and
   becomes unclickable. Do not add entrance animation to this element. */

/* let action bars wrap gracefully instead of overflowing on narrow screens */
.card-header.d-flex, .tx-main > .d-flex { flex-wrap: wrap; row-gap: .5rem; }

@media (max-width: 575.98px) {
    .tx-main { padding-inline: .85rem !important; }
    .tx-search-box .form-control { width: 100%; }
    .tx-stat-card { padding: .7rem .85rem; }
}

/* ============================================================
   Login (auth) page
   ============================================================ */
body.tx-auth {
    min-height: 100vh; margin: 0;
    background: var(--tx-grad); position: relative; overflow: hidden;
}
body.tx-auth::before, body.tx-auth::after {
    content: ""; position: absolute; border-radius: 50%;
    background: rgba(255,255,255,.12); filter: blur(2px);
    animation: tx-float 9s ease-in-out infinite;
}
body.tx-auth::before { width: 420px; height: 420px; top: -120px; inset-inline-end: -80px; }
body.tx-auth::after  { width: 320px; height: 320px; bottom: -120px; inset-inline-start: -60px; animation-delay: -4s; }
@keyframes tx-float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-22px) } }

.tx-auth-card {
    background: rgba(255,255,255,.97); backdrop-filter: blur(6px);
    border-radius: 1.1rem; box-shadow: 0 24px 60px rgba(16,24,40,.30);
    border: 1px solid rgba(255,255,255,.5);
    animation: tx-rise .5s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes tx-rise { from { opacity: 0; transform: translateY(18px) scale(.98) } to { opacity: 1; transform: none } }

.tx-auth-logo {
    width: 60px; height: 60px; border-radius: 16px; margin: 0 auto;
    background: var(--tx-grad); display: grid; place-items: center;
    color: #fff; font-weight: 800; font-size: 1.6rem;
    box-shadow: 0 10px 24px rgba(230,81,0,.45);
}
.tx-auth-card .form-control, .tx-auth-card .form-select { padding: .6rem .8rem; border-radius: .6rem; }
.tx-auth-card .input-group-text { background: var(--tx-orange-50); border-color: #e7e9ee; color: var(--tx-orange-700); }
.tx-auth-card .btn-primary { padding: .65rem; font-weight: 600; letter-spacing: .3px; }
.tx-auth-foot { color: rgba(255,255,255,.92); text-shadow: 0 1px 2px rgba(0,0,0,.18); }

/* ============================================================
   Chart-of-accounts tree
   ============================================================ */
.tx-tree, .tx-tree-children { list-style: none; margin: 0; padding: 0; }
.tx-tree-children { padding-inline-start: 22px; position: relative; }
.tx-tree-children::before {
    content: ""; position: absolute; inset-inline-start: 9px; top: 0; bottom: 14px;
    border-inline-start: 1px dashed #d7dbe3;
}
.tx-tree-item.collapsed > .tx-tree-children { display: none; }
.tx-tree-item.collapsed > .tx-tree-row .tx-caret i { transform: rotate(-90deg); }

.tx-tree-row {
    display: flex; align-items: center; gap: .4rem; padding: .3rem .5rem; border-radius: 8px;
    transition: background .12s ease;
}
.tx-tree-row:hover { background: var(--tx-orange-50); }
.tx-tree-row.is-parent { font-weight: 600; }

.tx-caret { border: 0; background: transparent; color: var(--tx-muted); width: 20px; cursor: pointer; padding: 0; }
.tx-caret i { transition: transform .15s ease; display: inline-block; }
.tx-caret-spacer { width: 20px; display: inline-block; }
.tx-tree-icon { width: 18px; text-align: center; }
.tx-acc-code {
    background: #eef1f6; color: #475067; border-radius: 6px; padding: 1px 7px; font-size: .8rem;
}
.tx-acc-name { color: #232a36; }
.tx-acc-actions {
    margin-inline-start: auto; display: flex; align-items: center; gap: .3rem;
    opacity: 0; transition: opacity .12s ease;
}
.tx-tree-row:hover .tx-acc-actions { opacity: 1; }
.tx-acc-actions form { display: contents; }
.tx-acc-action {
    border: 0; background: transparent; color: var(--tx-muted);
    padding: 3px 6px; border-radius: 6px; line-height: 1; display: inline-flex;
}
.tx-acc-action:hover { color: var(--tx-orange-700); background: var(--tx-orange-50); }
.tx-acc-add:hover { color: #1a7f37; background: #eaf7ee; }
.tx-acc-delete:hover { color: #b42318; background: #fdecea; }

/* ============================================================
   Grouped form sections (e.g. account create/edit)
   ============================================================ */
.tx-form-section { padding-block: 1rem 1.25rem; border-bottom: 1px solid rgba(16,24,40,.06); }
.tx-form-section:last-of-type { border-bottom: 0; padding-bottom: .25rem; }
.tx-form-section-title {
    color: var(--tx-orange-700); font-weight: 700; letter-spacing: .2px;
    text-transform: uppercase; font-size: .72rem; margin-bottom: .9rem;
}
.tx-form-section-title i { margin-inline-end: .35rem; }
#parentPath { color: var(--tx-muted); }

/* ============================================================
   Stat cards (e.g. chart-of-accounts summary strip)
   ============================================================ */
.tx-stat-card {
    display: flex; align-items: center; gap: .8rem; background: #fff;
    border: 1px solid rgba(16,24,40,.06); border-radius: .8rem; box-shadow: var(--tx-shadow);
    padding: .85rem 1rem;
}
.tx-stat-icon {
    width: 42px; height: 42px; border-radius: .65rem; display: grid; place-items: center;
    background: var(--tx-orange-50); color: var(--tx-orange-700); font-size: 1.1rem; flex: none;
}
.tx-stat-icon-ok { background: #eaf7ee; color: #1a7f37; }
.tx-stat-icon-hdr { background: #eef1f6; color: #475067; }
.tx-stat-icon-warn { background: #fff6e6; color: #b45309; }
.tx-stat-value { font-size: 1.25rem; font-weight: 700; color: var(--tx-ink); line-height: 1.1; }
.tx-stat-label { color: var(--tx-muted); font-size: .78rem; }
.tx-stat-card-active { border-color: var(--tx-orange); box-shadow: 0 0 0 2px rgba(245,124,0,.18), var(--tx-shadow); }

/* ============================================================
   Account mapping page
   ============================================================ */
.tx-map-group .tx-form-section-title { margin-bottom: .5rem; }
tr.tx-map-pending { background: #fffaf0; }
.tx-entity-grid { max-height: 360px; overflow-y: auto; border: 1px solid rgba(16,24,40,.06); border-radius: .6rem; }
.tx-entity-grid table { margin-bottom: 0; }
.tx-entity-grid thead th { position: sticky; top: 0; background: #f8f9fb; z-index: 1; }

/* ============================================================
   Transaction-grid row selection + bulk action bar
   ============================================================ */

/* The select column stays narrow and centred, and never wraps when the grid is scrolled
   horizontally on a small screen. */
.tx-check-col { width: 2.4rem; text-align: center; padding-inline: .4rem !important; }
.tx-check-col .form-check-input { margin: 0; cursor: pointer; }

/* A selected row is tinted rather than outlined: the grids are dense and an outline on every
   picked row turns 20 selections into visual noise. :has() keeps this in CSS instead of making
   the JS toggle a class on every refresh. */
.table > tbody > tr:has(.tx-row-check:checked) { background-color: var(--tx-orange-50); }
.table-hover > tbody > tr:has(.tx-row-check:checked):hover { background-color: #ffecd6; }

/* Pinned to the bottom of the viewport so the actions stay reachable however far the grid is
   scrolled — the reason to select 40 rows is to act on them without scrolling back up. */
.tx-bulkbar {
    position: sticky; bottom: 0; z-index: 3;
    margin-top: .75rem; padding-bottom: .25rem;
    animation: tx-bulkbar-in .16s var(--tx-ease);
}
.tx-bulkbar[hidden] { display: none; }
.tx-bulkbar-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    background: #fff; border: 1px solid var(--tx-orange-300); border-radius: .7rem;
    box-shadow: var(--tx-shadow-md); padding: .55rem .85rem;
}
.tx-bulkbar-count {
    display: inline-flex; align-items: center; gap: .45rem;
    font-weight: 600; color: var(--tx-ink); font-size: .88rem; white-space: nowrap;
}
.tx-bulkbar-count > i { color: var(--tx-orange-700); }
.tx-bulkbar-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.tx-bulkbar-actions .badge { font-size: .68rem; font-weight: 700; }

/* A disabled bulk button means "none of what you picked qualifies", which is information worth
   keeping legible — so it dims rather than fading most of the way out. */
.tx-bulkbar-actions .btn:disabled { opacity: .45; }

@keyframes tx-bulkbar-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .tx-bulkbar { animation: none; }
}

/* The bar is a live control; it has no meaning on paper. */
@media print {
    .tx-bulkbar, .tx-check-col { display: none !important; }
}

/* ============================================================
   Financial statements (Balance Sheet / Income Statement)
   ============================================================ */
.tx-stmt-header { background: var(--tx-orange-50); }
.tx-stmt-card .card-header { font-size: .92rem; }

.tx-search-box { position: relative; }
.tx-search-box i {
    position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%);
    color: var(--tx-muted); font-size: .8rem; pointer-events: none;
}
.tx-search-box .form-control { width: 220px; padding-inline-start: 28px; }

/* ============================================================
   Item picker — the document-entry search result list
   (Sales invoice entry; reusable by any doc that picks items).
   Each row carries name + category/class/barcode + price + cost
   + stock, so the whole decision is made without leaving the row.
   ============================================================ */
.tx-pick { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.tx-pick-item {
    display: flex; align-items: center; gap: .75rem; width: 100%;
    padding: .5rem .625rem; border: 1px solid transparent; border-radius: .5rem;
    background: transparent; text-align: start; cursor: pointer;
    transition: background-color .15s var(--tx-ease), border-color .15s var(--tx-ease);
}
.tx-pick-item:hover { background: var(--tx-orange-50); border-color: rgba(245,124,0,.22); }
.tx-pick-item:focus-visible,
.tx-pick-item.tx-pick-active {
    outline: none; background: var(--tx-orange-50); border-color: var(--tx-orange);
    box-shadow: 0 0 0 2px rgba(245,124,0,.16);
}
.tx-pick-item[disabled] { opacity: .5; cursor: not-allowed; }
.tx-pick-item[disabled]:hover { background: transparent; border-color: transparent; }

.tx-pick-body { min-width: 0; flex: 1 1 auto; }
.tx-pick-name {
    font-size: .875rem; font-weight: 600; color: var(--tx-ink); line-height: 1.35;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tx-pick-name mark { background: rgba(245,124,0,.22); color: inherit; padding: 0; border-radius: 2px; }
.tx-pick-meta {
    display: flex; align-items: center; gap: .35rem; margin-top: .2rem;
    font-size: .72rem; color: var(--tx-muted); min-width: 0;
}
.tx-pick-chip {
    display: inline-block; max-width: 11ch; padding: .05rem .35rem; border-radius: .3rem;
    background: #eef1f6; color: #55607a; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tx-pick-chip-class { background: #f1eef6; color: #5f5580; }
.tx-pick-barcode { font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Right rail: price leads, cost is deliberately quiet beneath it — cost is
   reference data for the seller, not the number being transacted. */
.tx-pick-rail { flex: none; text-align: end; }
.tx-pick-price { font-size: .875rem; font-weight: 700; color: var(--tx-ink); font-variant-numeric: tabular-nums; line-height: 1.35; }
.tx-pick-cost { font-size: .7rem; color: var(--tx-muted); font-variant-numeric: tabular-nums; margin-top: .2rem; }

.tx-stock-pill {
    flex: none; min-width: 4.25rem; text-align: center;
    padding: .2rem .4rem; border-radius: .4rem;
    font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tx-stock-ok   { background: #eaf7ee; color: #1a7f37; }
.tx-stock-low  { background: #fff6e6; color: #b45309; }
.tx-stock-out  { background: #fdecec; color: #b42318; }
.tx-stock-na   { background: #f1f3f7; color: #8a93a6; }

.tx-pick-empty { padding: 1.75rem .75rem; text-align: center; color: var(--tx-muted); font-size: .82rem; }

/* In-flight item search. Same footprint as the empty state so the list doesn't
   jump between "loading" and "nothing matched". */
.tx-pick-loading {
    padding: 1.75rem .75rem; text-align: center; color: var(--tx-muted); font-size: .82rem;
    display: flex; align-items: center; justify-content: center; gap: .5rem;
}

/* Cart line that oversells the on-hand balance — a warning, never a blocker
   under periodic costing (which legitimately allows negative stock). */
tr.tx-line-short { background: #fffaf0; }
tr.tx-line-short td { border-color: rgba(180,83,9,.18); }

/* Totals panel — one number wins. */
.tx-totals { border-top: 1px solid rgba(16,24,40,.08); padding-top: .875rem; }
.tx-totals-row {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    font-size: .82rem; color: var(--tx-muted); padding-block: .2rem;
}
.tx-totals-row span:last-child { color: var(--tx-ink); font-variant-numeric: tabular-nums; }
.tx-totals-grand {
    display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
    margin-top: .625rem; padding-top: .625rem; border-top: 1px solid rgba(16,24,40,.08);
}
.tx-totals-grand-label { font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--tx-muted); }
.tx-totals-grand-value { font-size: 1.75rem; font-weight: 700; color: var(--tx-ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ============================================================
   Reports — shared primitives for the wide numeric grids
   (Item Balances, Stock Card, Inventory Valuation, ...).
   These screens are read column-down, not row-across: the eye
   compares one measure across many rows. Everything here serves
   that — figures that line up, groups that separate, one column
   allowed to win.
   ============================================================ */

/* Proportional digits leave a right-aligned numeric column ragged (a "1" is
   narrower than an "8"), which defeats column-down scanning and reads as
   sloppy. Same tabular-figure treatment the totals panel and item picker
   already use — this just names it so report grids can share it. */
.tx-num { font-variant-numeric: tabular-nums; text-align: end; white-space: nowrap; }

/* A zero carries no information in a ledger. Keep it for alignment, but let
   the eye skip past it to the rows that matter. */
.tx-zero { color: #c3c9d4; }

/* Reuses the semantic pair already established by .tx-stock-ok/.tx-stock-out. */
.tx-neg { color: #b42318; font-weight: 600; }
.tx-pos { color: #1a7f37; font-weight: 600; }

.tx-rpt { margin-bottom: 0; }
.tx-rpt thead th {
    background: #f8f9fb; color: #55607a;
    font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
    white-space: nowrap; border-bottom: 1px solid rgba(16,24,40,.10);
}
.tx-rpt tbody td { font-size: .82rem; vertical-align: middle; }
.tx-rpt tfoot td {
    background: #f8f9fb; font-weight: 700; color: var(--tx-ink);
    border-top: 2px solid rgba(16,24,40,.14);
}

/* Column-group divider. Logical property, so it lands on the correct edge
   when the app flips to RTL for Arabic. */
.tx-grp { border-inline-start: 1px solid rgba(16,24,40,.10); }

/* The column that wins: a ledger's running balance, a report's headline
   measure. Exactly one per table — if two compete, neither reads. */
.tx-rpt .tx-lead { font-weight: 700; color: var(--tx-ink); }

/* Long report bodies scroll under a pinned header rather than making the
   user lose the column meanings on the way down. Single-row headers only. */
.tx-rpt-scroll { max-height: 68vh; overflow: auto; }
.tx-rpt-scroll .tx-rpt thead th { position: sticky; top: 0; z-index: 2; }

/* ============================================================
   Dashboard
   ============================================================ */
.tx-kpi {
    position: relative; overflow: hidden; height: 100%;
    background: #fff; border: 1px solid rgba(16,24,40,.06); border-radius: .85rem;
    box-shadow: var(--tx-shadow); padding: 1rem 1.15rem;
    transition: transform .15s var(--tx-ease), box-shadow .15s var(--tx-ease);
}
.tx-kpi:hover { transform: translateY(-2px); box-shadow: var(--tx-shadow-md); }
.tx-kpi::after { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--tx-grad); }
.tx-kpi-sales::after    { background: linear-gradient(180deg,#22a559,#15803d); }
.tx-kpi-month::after    { background: var(--tx-grad); }
.tx-kpi-purchase::after { background: linear-gradient(180deg,#22b8cf,#0e7490); }
.tx-kpi-net::after      { background: linear-gradient(180deg,#8b5cf6,#6d28d9); }
.tx-kpi-label { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--tx-muted); }
.tx-kpi-value { font-size: 1.55rem; font-weight: 800; color: var(--tx-ink); letter-spacing: -.02em; line-height: 1.1; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.tx-kpi-sub { font-size: .75rem; color: var(--tx-muted); margin-top: .3rem; }
.tx-kpi-icon { position: absolute; inset-inline-end: .85rem; top: .8rem; font-size: 1.35rem; opacity: .16; }

.tx-delta { display: inline-flex; align-items: center; gap: .15rem; font-weight: 700; font-size: .72rem; padding: .05rem .4rem; border-radius: .4rem; font-variant-numeric: tabular-nums; }
.tx-delta-up   { background: #eaf7ee; color: #1a7f37; }
.tx-delta-down { background: #fdecec; color: #b42318; }
.tx-delta-flat { background: #eef1f6; color: #55607a; }

/* Inline SVG sales trend — no external chart lib, so it works offline. */
.tx-chart { width: 100%; height: 240px; display: block; }
.tx-chart-baseline { stroke: rgba(16,24,40,.10); stroke-width: 1; }
.tx-chart-line { fill: none; stroke: var(--tx-orange); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.tx-chart-dot { fill: #fff; stroke: var(--tx-orange-600); stroke-width: 2; }
.tx-chart-label { fill: var(--tx-muted); font-size: 11px; }
.tx-chart-empty { color: var(--tx-muted); text-align: center; padding: 3rem 0; }

/* Top-items ranked list */
.tx-toplist { list-style: none; margin: 0; padding: 0; }
.tx-toplist li { padding: .55rem 0; border-bottom: 1px solid rgba(16,24,40,.05); }
.tx-toplist li:last-child { border-bottom: 0; }
.tx-toprow { display: flex; align-items: center; gap: .6rem; }
.tx-toprank { width: 1.6rem; height: 1.6rem; border-radius: .45rem; background: var(--tx-orange-50); color: var(--tx-orange-700); font-weight: 700; font-size: .8rem; display: grid; place-items: center; flex: none; }
.tx-topname { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-topval { font-weight: 700; font-variant-numeric: tabular-nums; font-size: .85rem; white-space: nowrap; }
.tx-topbar { height: 6px; border-radius: 3px; background: #eef1f6; overflow: hidden; margin-top: .35rem; }
.tx-topbar > span { display: block; height: 100%; background: var(--tx-grad); border-radius: 3px; }

/* ============================================================
   Print — the app chrome disappears, the content prints clean.
   Ctrl+P on any list/report page gives a usable hard copy without
   a dedicated "print view" per screen.
   ============================================================ */
@media print {
    #sidebar, header.navbar, footer, .tx-sidebar-backdrop, .tx-skip-link,
    .btn, .alert-warning { display: none !important; }
    body, #app-wrapper { background: #fff !important; }
    .tx-main { padding: 0 !important; }
    .card { box-shadow: none !important; border-color: #d5d9e0 !important; break-inside: avoid; }
    /* Scrolling grids print in full instead of clipping at their on-screen max-height */
    .tx-entity-grid, .tx-rpt-scroll { max-height: none !important; overflow: visible !important; }
    /* A sticky header repeats itself mid-page on paper — let it print as a normal row */
    .tx-rpt-scroll .tx-rpt thead th { position: static !important; }
    .table-responsive { overflow: visible !important; }
    a { color: inherit !important; }
}
