/*
 * BuildTrack Kuwait - Professional UI layer
 * Loaded after site.css to unify the accumulated page styles without changing business views.
 */

:root {
    --app-bg: #f3f5f7;
    --app-surface: #ffffff;
    --app-surface-alt: #f8fafc;
    --app-surface-warm: #fbf8f3;
    --app-text: #17212b;
    --app-muted: #667085;
    --app-subtle: #98a2b3;
    --app-line: #e4e7ec;
    --app-brand: #8b6842;
    --app-brand-strong: #66492e;
    --app-brand-soft: #f0e6d8;
    --app-nav: #18202a;
    --app-nav-2: #202b37;
    --app-success: #16835d;
    --app-warning: #b7791f;
    --app-danger: #c2414b;
    --app-info: #3568a8;
    --app-radius-xs: 10px;
    --app-radius-sm: 14px;
    --app-radius: 18px;
    --app-radius-lg: 24px;
    --app-shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .04);
    --app-shadow: 0 12px 34px rgba(16, 24, 40, .08);
    --app-shadow-lg: 0 24px 70px rgba(16, 24, 40, .16);
    --app-header-h: 74px;
    --app-mobile-header-h: 64px;
    --app-bottom-nav-h: 76px;
}

html {
    background: var(--app-bg);
    color-scheme: light;
    scroll-behavior: auto !important;
    -webkit-text-size-adjust: 100%;
}

body.app-body,
body.final-login-body {
    background: var(--app-bg) !important;
    color: var(--app-text);
    min-width: 320px;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.app-body {
    min-height: 100svh;
}

body.quick-search-open,
body.app-sheet-open {
    overflow: hidden !important;
}

::selection {
    background: rgba(139, 104, 66, .2);
}

/* ---------- shared typography ---------- */
.app-body h1,
.app-body h2,
.app-body h3,
.app-body h4,
.app-body h5,
.app-body h6,
.final-login-body h1,
.final-login-body h2 {
    color: var(--app-text);
    letter-spacing: -.015em;
}

.text-muted,
.muted {
    color: var(--app-muted) !important;
}

/* ---------- app shell ---------- */
.app-shell {
    min-height: 100svh !important;
    background: var(--app-bg);
}

.sidebar {
    width: 272px !important;
    padding: 18px 14px 16px !important;
    background:
        radial-gradient(circle at 20% 0%, rgba(139, 104, 66, .28), transparent 34%),
        linear-gradient(180deg, var(--app-nav-2), var(--app-nav)) !important;
    border-inline-end: 1px solid rgba(255, 255, 255, .06);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

.sidebar .brand,
.mobile-offcanvas .brand {
    margin: 0 0 18px !important;
    padding: 8px 8px 14px !important;
    gap: 11px !important;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-icon,
.app-brand-mark {
    width: 46px !important;
    height: 46px !important;
    flex: 0 0 46px;
    border-radius: 15px !important;
    background: linear-gradient(145deg, #b18b5d, var(--app-brand)) !important;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
    color: #fff;
    display: grid;
    place-items: center;
}

.brand strong {
    color: #fff;
    font-size: 15px !important;
    line-height: 1.35;
}

.brand span {
    color: rgba(255, 255, 255, .58) !important;
    font-size: 11.5px !important;
    margin-top: 3px !important;
}

.sidebar nav {
    gap: 3px !important;
}

.sidebar .nav-link,
.mobile-nav .nav-link {
    position: relative;
    min-height: 44px;
    border-radius: 13px !important;
    padding: 10px 12px !important;
    color: rgba(255, 255, 255, .68) !important;
    font-size: 13.5px;
    font-weight: 700 !important;
    line-height: 1.35;
    gap: 10px !important;
    transition: background-color .15s ease, color .15s ease, transform .15s ease;
}

.sidebar .nav-link > i:first-child,
.mobile-nav .nav-link > i:first-child {
    width: 21px;
    text-align: center;
    font-size: 17px;
    opacity: .9;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active,
.mobile-nav .nav-link:hover,
.mobile-nav .nav-link.active {
    background: rgba(255, 255, 255, .095) !important;
    color: #fff !important;
}

.sidebar .nav-link.active::before {
    content: "";
    position: absolute;
    inset-inline-start: -7px;
    top: 11px;
    bottom: 11px;
    width: 3px;
    border-radius: 99px;
    background: #d7b17b;
}

.sidebar .admin-submenu,
.mobile-nav .admin-submenu {
    margin: 2px 8px 7px 0;
    padding-inline-start: 7px;
    border-inline-start: 1px solid rgba(255, 255, 255, .1);
}

.sidebar .admin-submenu .nav-link,
.mobile-nav .admin-submenu .nav-link {
    min-height: 38px;
    font-size: 12.5px;
    padding-block: 8px !important;
}

.sidebar-footer {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-install-card {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .055);
    color: #fff;
    border-radius: 15px;
    padding: 11px 12px;
    text-align: start;
}

.sidebar-install-card:hover {
    background: rgba(255, 255, 255, .09);
}

.sidebar-install-card .install-icon {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: rgba(215, 177, 123, .18);
    color: #e5c79c;
    display: grid;
    place-items: center;
    font-size: 17px;
}

.sidebar-install-card strong,
.sidebar-install-card small {
    display: block;
}

.sidebar-install-card strong {
    font-size: 12.5px;
}

.sidebar-install-card small {
    color: rgba(255, 255, 255, .55);
    font-size: 10.5px;
    margin-top: 2px;
}

.main-content {
    min-width: 0;
    min-height: 100svh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1015;
    min-height: var(--app-header-h);
    padding: 14px 28px !important;
    background: rgba(243, 245, 247, .88) !important;
    backdrop-filter: blur(16px) saturate(130%);
    -webkit-backdrop-filter: blur(16px) saturate(130%);
    border-bottom: 1px solid rgba(228, 231, 236, .76);
}

.topbar-copy {
    min-width: 0;
}

.topbar-eyebrow {
    color: var(--app-brand);
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 2px;
}

.topbar h1 {
    color: var(--app-text);
    font-size: 22px !important;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-actions {
    flex-wrap: nowrap !important;
}

.topbar-user-chip {
    height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 11px 0 8px;
    border-radius: 13px;
    border: 1px solid var(--app-line);
    background: rgba(255, 255, 255, .84);
    color: var(--app-text);
    font-size: 12px;
    font-weight: 700;
}

.topbar-user-chip i {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--app-brand-soft);
    color: var(--app-brand);
    font-size: 15px;
}

.content-wrap {
    width: 100%;
    max-width: 1680px;
    margin-inline: auto;
    padding: 22px 28px 40px !important;
}

/* ---------- surfaces and cards ---------- */
.clean-card,
.card,
[class*="-filter-card"],
.search-box-card {
    background: var(--app-surface) !important;
    border: 1px solid var(--app-line) !important;
    border-radius: var(--app-radius) !important;
    box-shadow: var(--app-shadow-sm) !important;
}

.clean-card:hover {
    border-color: #d8dce2;
}

.hero-card {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 8% 20%, rgba(139, 104, 66, .12), transparent 28%),
        linear-gradient(145deg, #fff 0%, #fbf8f3 100%) !important;
}

.hero-card::after {
    content: "";
    position: absolute;
    width: 170px;
    height: 170px;
    border-radius: 50%;
    inset-inline-end: -70px;
    top: -90px;
    background: rgba(139, 104, 66, .06);
    pointer-events: none;
}

.page-actions {
    margin-bottom: 14px !important;
}

.page-actions h2 {
    font-size: 20px !important;
}

.kpi-card {
    min-height: 128px;
    padding: 19px !important;
}

.kpi-card .label {
    color: var(--app-muted) !important;
    font-size: 12.5px !important;
    font-weight: 700;
}

.kpi-card .value {
    color: var(--app-text);
    font-size: clamp(19px, 1.7vw, 27px) !important;
    letter-spacing: -.02em;
}

.kpi-card .icon {
    width: 42px !important;
    height: 42px !important;
    border-radius: 13px !important;
    background: var(--app-brand-soft) !important;
    color: var(--app-brand) !important;
}

.badge-soft {
    background: var(--app-brand-soft) !important;
    color: var(--app-brand-strong) !important;
    border: 1px solid rgba(139, 104, 66, .12);
    border-radius: 999px;
    padding: .48em .72em;
}

.mini-stat {
    height: 100%;
    border-radius: 14px !important;
    background: var(--app-surface-alt) !important;
    border: 1px solid #edf0f3;
}

.progress {
    background: #eceff2 !important;
}

.progress-bar {
    background: linear-gradient(90deg, var(--app-brand), #b58c5d) !important;
}

/* ---------- forms ---------- */
.form-label {
    color: #344054;
    font-size: 12.5px;
    font-weight: 800;
    margin-bottom: 6px;
}

.form-control,
.form-select,
.select2-container--bootstrap-5 .select2-selection {
    min-height: 46px;
    color: var(--app-text) !important;
    background-color: #fff !important;
    border: 1px solid #d9dde3 !important;
    border-radius: 13px !important;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .02);
    transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}

.form-control:hover,
.form-select:hover,
.select2-container--bootstrap-5 .select2-selection:hover {
    border-color: #c5cbd3 !important;
}

.form-control:focus,
.form-select:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--app-brand) !important;
    box-shadow: 0 0 0 3px rgba(139, 104, 66, .12) !important;
}

.form-control::placeholder {
    color: #a3aab5;
}

.input-group-text {
    background: var(--app-surface-alt) !important;
    color: var(--app-muted);
    border-color: #d9dde3 !important;
}

textarea.form-control {
    min-height: 112px;
    resize: vertical;
}

.form-check-input:checked {
    background-color: var(--app-brand);
    border-color: var(--app-brand);
}

.form-text {
    color: var(--app-subtle);
    font-size: 11.5px;
}

/* ---------- buttons ---------- */
.btn {
    min-height: 42px;
    border-radius: 12px !important;
    padding-inline: 15px;
    font-size: 13px;
    font-weight: 800 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: none !important;
    transition: background-color .14s ease, border-color .14s ease, color .14s ease, transform .1s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: linear-gradient(145deg, #987249, var(--app-brand)) !important;
    border-color: var(--app-brand) !important;
    color: #fff !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(145deg, #84603c, var(--app-brand-strong)) !important;
    border-color: var(--app-brand-strong) !important;
}

.btn-outline-primary {
    color: var(--app-brand) !important;
    border-color: rgba(139, 104, 66, .42) !important;
    background: #fff;
}

.btn-outline-primary:hover {
    color: #fff !important;
    background: var(--app-brand) !important;
    border-color: var(--app-brand) !important;
}

.btn-outline-secondary,
.btn-light {
    color: #475467 !important;
    border-color: #d9dde3 !important;
    background: #fff !important;
}

.btn-outline-secondary:hover,
.btn-light:hover {
    background: var(--app-surface-alt) !important;
    color: var(--app-text) !important;
}

.btn-sm {
    min-height: 36px;
    border-radius: 10px !important;
    padding-inline: 11px;
    font-size: 12px;
}

/* ---------- tables ---------- */
.table-responsive {
    border-radius: 14px;
    scrollbar-width: thin;
}

.table {
    margin-bottom: 0;
    color: var(--app-text);
}

.table > :not(caption) > * > * {
    padding: .82rem .76rem;
    border-bottom-color: #edf0f3;
}

.table thead th {
    background: #f8fafb !important;
    color: #667085 !important;
    font-size: 11.5px !important;
    font-weight: 800;
    white-space: nowrap;
    border-bottom: 1px solid #e4e7ec !important;
}

.table tbody tr {
    transition: background-color .12s ease;
}

.table tbody tr:hover {
    background: #fafbfc;
}

.table-actions {
    gap: 5px !important;
}

.dataTables_wrapper .dt-search input,
.dataTables_wrapper .dt-length select,
.dt-search input,
.dt-length select {
    min-height: 38px;
    border: 1px solid #d9dde3 !important;
    background: #fff;
}

.pagination .page-link {
    min-width: 36px;
    min-height: 36px;
    display: grid;
    place-items: center;
    color: #475467;
    border-color: #e4e7ec;
}

.pagination .active > .page-link,
.pagination .page-link.active {
    background: var(--app-brand);
    border-color: var(--app-brand);
}

/* ---------- dialogs / sheets ---------- */
.modal-backdrop.show {
    opacity: .42;
    backdrop-filter: blur(2px);
}

.modal-content {
    border: 1px solid rgba(255, 255, 255, .78) !important;
    border-radius: 22px !important;
    box-shadow: var(--app-shadow-lg) !important;
    overflow: hidden;
}

.modal-header,
.modal-footer {
    border-color: #edf0f3 !important;
    background: #fff;
}

.modal-header {
    padding: 16px 18px;
}

.modal-body {
    padding: 18px;
}

.modal-footer {
    padding: 13px 18px;
}

.offcanvas.mobile-offcanvas {
    background:
        radial-gradient(circle at 20% 0%, rgba(139, 104, 66, .25), transparent 32%),
        linear-gradient(180deg, var(--app-nav-2), var(--app-nav)) !important;
    color: #fff;
    border: 0 !important;
}

.mobile-offcanvas .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.mobile-offcanvas .offcanvas-body {
    display: flex;
    flex-direction: column;
}

.mobile-offcanvas .mobile-nav {
    flex: 1;
}

.mobile-offcanvas .sidebar-footer {
    margin-top: auto;
}

.quick-add-overlay,
.quick-search-overlay {
    background: rgba(12, 18, 25, .46) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.quick-add-sheet,
.quick-search-panel {
    border: 1px solid rgba(255, 255, 255, .7);
    box-shadow: var(--app-shadow-lg) !important;
}

.quick-add-sheet {
    border-radius: 24px 24px 0 0 !important;
}

.quick-add-row {
    border-radius: 14px !important;
}

.quick-add-row:hover {
    background: var(--app-surface-warm) !important;
}

.quick-search-panel {
    border-radius: 22px !important;
}

.page-loader {
    background: rgba(243, 245, 247, .72) !important;
    backdrop-filter: blur(8px) !important;
}

.page-loader-box {
    width: 72px;
    height: 72px;
    padding: 0 !important;
    border-radius: 22px !important;
    background: rgba(255, 255, 255, .94) !important;
    box-shadow: var(--app-shadow) !important;
}

.page-loader-spinner {
    width: 30px !important;
    height: 30px !important;
    border-width: 3px !important;
}

/* ---------- mobile header / navigation ---------- */
.mobile-header {
    position: sticky !important;
    top: 0;
    z-index: 1025;
    min-height: calc(var(--app-mobile-header-h) + env(safe-area-inset-top)) !important;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px !important;
    background: rgba(24, 32, 42, .96) !important;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
}

.mobile-menu-btn,
.mobile-header-avatar {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
    min-height: 40px;
    border-radius: 13px !important;
    background: rgba(255, 255, 255, .09) !important;
    border: 1px solid rgba(255, 255, 255, .08) !important;
    color: #fff !important;
    font-size: 18px !important;
}

.mobile-brand {
    min-width: 0;
    flex: 1;
    display: flex !important;
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0 !important;
    padding-inline: 4px;
}

.mobile-brand small {
    color: rgba(255, 255, 255, .55);
    font-size: 10.5px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.mobile-brand strong {
    color: #fff;
    font-size: 14.5px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.mobile-header-actions {
    gap: 6px !important;
}

.bottom-tab-bar {
    height: calc(var(--app-bottom-nav-h) + env(safe-area-inset-bottom));
    padding: 5px 7px calc(5px + env(safe-area-inset-bottom)) !important;
    background: rgba(255, 255, 255, .96) !important;
    border-top: 1px solid rgba(228, 231, 236, .9) !important;
    box-shadow: 0 -10px 30px rgba(16, 24, 40, .09) !important;
    backdrop-filter: blur(18px) saturate(130%) !important;
    -webkit-backdrop-filter: blur(18px) saturate(130%) !important;
    transform: translateZ(0);
    transition: none !important;
}

.bottom-tab-item {
    min-width: 0;
    color: #84909d !important;
    border-radius: 12px !important;
    transition: none !important;
}

.bottom-tab-item.active {
    color: var(--app-brand) !important;
}

.bottom-tab-icon {
    font-size: 19px !important;
    transition: none !important;
}

.bottom-tab-item.active .bottom-tab-icon {
    transform: none !important;
}

.bottom-tab-label {
    font-size: 10.5px;
    line-height: 1.2;
}

.bottom-tab-indicator {
    width: 48px !important;
    height: 34px !important;
    border-radius: 12px !important;
    background: var(--app-brand-soft) !important;
}

.bottom-tab-fab-wrap {
    top: -14px !important;
}

.bottom-tab-fab {
    width: 52px !important;
    height: 52px !important;
    background: linear-gradient(145deg, #9b744a, var(--app-brand-strong)) !important;
    border: 4px solid var(--app-bg) !important;
    box-shadow: 0 12px 26px rgba(102, 73, 46, .34) !important;
    transition: none !important;
}

/* ---------- mobile cards: unify all entity views ---------- */
@media (max-width: 991.98px) {
    .main-content {
        min-height: calc(var(--app-viewport-height, 100svh) - var(--app-mobile-header-h));
    }

    .content-wrap {
        padding: 16px 12px calc(var(--app-bottom-nav-h) + env(safe-area-inset-bottom) + 18px) !important;
    }

    .stat-strip {
        gap: 10px !important;
    }

    .clean-card,
    .card,
    [class*="-filter-card"] {
        border-radius: 17px !important;
    }

    .hero-card {
        padding: 18px !important;
    }

    .hero-card h2 {
        font-size: 19px;
    }

    .kpi-card {
        min-height: 108px;
        padding: 14px !important;
    }

    .kpi-card .value {
        font-size: 18px !important;
    }

    .kpi-card .icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 17px !important;
    }

    .page-actions {
        align-items: stretch !important;
    }

    .page-actions > .btn,
    .page-actions > a.btn {
        min-height: 44px;
    }

    .payment-mobile-row,
    .contract-mobile-row,
    .dailynote-mobile-row,
    .quote-mobile-row,
    .changeorder-mobile-row,
    .attachment-mobile-row,
    .contractor-mobile-row,
    .budget-item-mobile-row,
    .user-mobile-row,
    .detail-mobile-row,
    .contractor-detail-mobile-row {
        background: var(--app-surface) !important;
        border: 1px solid var(--app-line) !important;
        border-radius: 17px !important;
        box-shadow: var(--app-shadow-sm) !important;
        padding: 14px !important;
        margin-bottom: 9px !important;
    }

    .payment-mobile-title,
    .contract-mobile-title,
    .dailynote-mobile-title,
    .quote-mobile-title,
    .changeorder-mobile-title,
    .attachment-mobile-title,
    .contractor-mobile-title,
    .budget-item-mobile-name {
        color: var(--app-text) !important;
        font-size: 14px !important;
        font-weight: 850 !important;
    }

    .payment-mobile-amount,
    .contract-mobile-amount,
    .quote-mobile-amount,
    .changeorder-mobile-amount {
        color: var(--app-brand-strong) !important;
        font-size: 15px !important;
        font-weight: 900 !important;
    }

    .payment-mobile-meta,
    .contract-mobile-meta,
    .dailynote-mobile-meta,
    .quote-mobile-meta,
    .changeorder-mobile-meta,
    .attachment-mobile-meta,
    .contractor-mobile-meta {
        color: var(--app-muted) !important;
        font-size: 11.5px !important;
    }

    .payment-mobile-actions,
    .contract-mobile-actions,
    .dailynote-mobile-actions,
    .quote-mobile-actions,
    .changeorder-mobile-actions,
    .attachment-mobile-actions,
    .contractor-mobile-actions,
    .user-mobile-actions {
        padding-top: 10px;
        border-top: 1px solid #edf0f3;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .payment-mobile-actions::-webkit-scrollbar,
    .contract-mobile-actions::-webkit-scrollbar,
    .dailynote-mobile-actions::-webkit-scrollbar,
    .quote-mobile-actions::-webkit-scrollbar,
    .changeorder-mobile-actions::-webkit-scrollbar,
    .attachment-mobile-actions::-webkit-scrollbar,
    .contractor-mobile-actions::-webkit-scrollbar,
    .user-mobile-actions::-webkit-scrollbar {
        display: none;
    }

    .payment-mobile-actions .btn,
    .contract-mobile-actions .btn,
    .dailynote-mobile-actions .btn,
    .quote-mobile-actions .btn,
    .changeorder-mobile-actions .btn,
    .attachment-mobile-actions .btn,
    .contractor-mobile-actions .btn,
    .user-mobile-actions .btn {
        width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        border-radius: 11px !important;
        flex: 0 0 38px !important;
    }

    .modal-dialog {
        margin: auto 0 0 !important;
        max-width: none !important;
        min-height: 0 !important;
        align-items: flex-end !important;
    }

    .modal-content {
        max-height: min(88svh, calc(var(--app-viewport-height, 100svh) - 14px));
        border-radius: 24px 24px 0 0 !important;
        border-bottom: 0 !important;
    }

    .modal-header {
        padding-top: 17px;
    }

    .modal-header::before {
        content: "";
        position: absolute;
        top: 7px;
        left: 50%;
        width: 38px;
        height: 4px;
        border-radius: 99px;
        background: #d5d9df;
        transform: translateX(-50%);
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        padding-bottom: calc(13px + env(safe-area-inset-bottom));
    }

    .quick-search-panel {
        inset: calc(8px + env(safe-area-inset-top)) 8px auto !important;
        max-height: calc(var(--app-viewport-height, 100svh) - 16px - env(safe-area-inset-top));
        border-radius: 20px !important;
    }

    .quick-add-sheet {
        padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important;
    }

    .select2-dropdown {
        border-radius: 16px !important;
        box-shadow: var(--app-shadow-lg) !important;
        overflow: hidden;
    }

    .select2-search--dropdown {
        padding: 10px !important;
    }

    .select2-results__option {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 9px 12px !important;
    }
}

@media (max-width: 767.98px) {
    input,
    select,
    textarea,
    .form-control,
    .form-select,
    .select2-search__field {
        font-size: 16px !important;
    }

    .form-control,
    .form-select,
    .select2-container--bootstrap-5 .select2-selection {
        min-height: 48px !important;
    }

    .btn {
        min-height: 44px;
    }

    .table-responsive {
        margin-inline: -2px;
    }

    .app-toast-stack {
        top: calc(var(--app-mobile-header-h) + env(safe-area-inset-top) + 8px) !important;
    }

    .app-toast {
        width: min(100%, 420px);
        border-radius: 14px !important;
    }
}

@media (max-width: 420px) {
    .content-wrap {
        padding-inline: 10px !important;
    }

    .stat-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .kpi-card {
        min-width: 0;
    }

    .kpi-card .value {
        font-size: 16px !important;
    }
}

/* ---------- keyboard stability ---------- */
@media (max-width: 991.98px) {
    html.keyboard-open,
    html.keyboard-open body {
        scroll-behavior: auto !important;
    }

    html.keyboard-open .bottom-tab-bar {
        display: none !important;
    }

    html.keyboard-open .content-wrap {
        padding-bottom: 18px !important;
    }

    html.keyboard-open .mobile-header,
    html.keyboard-open .main-content,
    html.keyboard-open .content-wrap,
    html.keyboard-open .modal-content,
    html.keyboard-open .quick-search-panel,
    html.keyboard-open .select2-dropdown,
    html.keyboard-open .form-control,
    html.keyboard-open .form-select {
        transition: none !important;
        animation: none !important;
    }
}

/* ---------- install app prompt ---------- */
.app-install-dialog {
    position: fixed;
    inset: 0;
    z-index: 3500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(12, 18, 25, .5);
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
}

.app-install-dialog.is-open {
    display: flex;
}

.app-install-card {
    width: min(430px, 100%);
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 24px;
    padding: 22px;
    background: rgba(255, 255, 255, .98);
    box-shadow: var(--app-shadow-lg);
}

.app-install-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.app-install-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--app-brand-soft);
    color: var(--app-brand);
    font-size: 24px;
}

.app-install-card h3 {
    font-size: 18px;
    font-weight: 900;
    margin: 0 0 3px;
}

.app-install-card p {
    color: var(--app-muted);
    font-size: 13px;
    line-height: 1.75;
    margin: 0;
}

.app-install-steps {
    display: grid;
    gap: 8px;
    margin: 14px 0;
}

.app-install-step {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    padding: 10px 11px;
    border: 1px solid var(--app-line);
    border-radius: 13px;
    background: var(--app-surface-alt);
    color: #344054;
    font-size: 12.5px;
}

.app-install-step span {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--app-brand-soft);
    color: var(--app-brand-strong);
    font-weight: 900;
}

.app-install-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.app-install-actions .btn {
    flex: 1;
}

[data-install-app].is-installed {
    display: none !important;
}

/* ---------- login page ---------- */
.final-login-body {
    min-height: 100svh !important;
    background: #111820 !important;
}

.final-login-shell {
    position: relative;
    min-height: 100svh !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr) !important;
    background: #111820;
}

.final-login-visual {
    min-height: 100svh !important;
    padding: 38px clamp(30px, 4vw, 64px) 48px !important;
    background-position: center !important;
    isolation: isolate;
}

.final-login-visual::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(180deg, rgba(9, 14, 20, .66) 0%, rgba(9, 14, 20, .08) 42%, rgba(9, 14, 20, .84) 100%),
        linear-gradient(90deg, rgba(9, 14, 20, .12), transparent 55%);
}

.final-login-visual-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.final-login-badge {
    background: rgba(17, 24, 32, .48) !important;
    border-color: rgba(255, 255, 255, .2) !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
}

.login-security-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, .82);
    font-size: 11.5px;
    font-weight: 700;
}

.final-login-visual-bottom {
    max-width: 590px;
}

.final-login-visual-bottom h2 {
    max-width: 520px;
    font-size: clamp(30px, 3.5vw, 50px) !important;
    line-height: 1.22;
    margin: 0 0 14px !important;
    color: #fff !important;
    letter-spacing: -.035em;
}

.final-login-visual-bottom p {
    max-width: 530px !important;
    color: rgba(255, 255, 255, .75) !important;
    font-size: 15px !important;
    line-height: 1.9 !important;
}

.final-login-summary {
    gap: 10px !important;
}

.final-login-summary > div {
    flex: 0 1 190px !important;
    min-width: 150px !important;
    padding: 12px 14px !important;
    border-radius: 15px !important;
    background: rgba(17, 24, 32, .48) !important;
    border-color: rgba(255, 255, 255, .17) !important;
}

.final-login-panel {
    min-height: 100svh !important;
    padding: 32px clamp(28px, 4vw, 68px) !important;
    background: #f7f8fa !important;
}

.final-login-panel-inner {
    max-width: 430px !important;
}

.login-brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.final-login-logo {
    width: 52px !important;
    height: 52px !important;
    margin: 0 !important;
    border-radius: 16px !important;
    background: linear-gradient(145deg, #a37b4d, var(--app-brand-strong)) !important;
    color: #fff !important;
    box-shadow: 0 12px 28px rgba(102, 73, 46, .25);
}

.login-brand-copy strong,
.login-brand-copy span {
    display: block;
}

.login-brand-copy strong {
    color: var(--app-text);
    font-size: 15px;
    font-weight: 900;
}

.login-brand-copy span {
    color: var(--app-muted);
    font-size: 11.5px;
    margin-top: 2px;
}

.final-login-panel h1 {
    font-size: 28px !important;
    margin-bottom: 7px !important;
}

.final-login-panel > .final-login-panel-inner > p,
.login-intro {
    color: var(--app-muted) !important;
    font-size: 13.5px;
    margin-bottom: 24px !important;
}

.final-login-form .input-group {
    position: relative;
}

.final-login-form .input-group-text,
.final-login-form .form-control {
    min-height: 52px !important;
    background: #fff !important;
    border-color: #d9dde3 !important;
}

.final-login-form .input-group-text {
    width: 48px;
    justify-content: center;
    color: #7a8491;
}

.final-login-form .form-control {
    font-size: 15px;
}

.final-login-form .form-control:focus {
    position: relative;
    z-index: 3;
}

.password-toggle {
    width: 45px;
    border: 1px solid #d9dde3;
    border-inline-start: 0;
    background: #fff;
    color: #7a8491;
}

.final-login-submit {
    min-height: 52px !important;
    border-radius: 14px !important;
    box-shadow: 0 14px 30px rgba(102, 73, 46, .22) !important;
}

.login-install-button {
    width: 100%;
    min-height: 46px;
    margin-top: 10px;
    border: 1px solid #d9dde3;
    border-radius: 13px;
    background: transparent;
    color: #475467;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 800;
}

.login-install-button:hover {
    background: #fff;
}

.login-footer-note {
    margin-top: 20px;
    color: #98a2b3;
    font-size: 11px;
    text-align: center;
}

/* ---------- loading screen ---------- */
#appBootLoader {
    background: var(--app-bg) !important;
    gap: 13px !important;
}

#appBootLoader .boot-icon {
    width: 58px !important;
    height: 58px !important;
    border-radius: 18px !important;
    background: linear-gradient(145deg, #9b744a, var(--app-brand-strong)) !important;
    box-shadow: 0 14px 34px rgba(102, 73, 46, .25) !important;
}

#appBootLoader .boot-spinner {
    width: 22px !important;
    height: 22px !important;
    border-width: 2px !important;
}

/* ---------- login mobile ---------- */
@media (max-width: 991.98px) {
    .final-login-body {
        background: #111820 !important;
    }

    .final-login-shell {
        display: block !important;
        min-height: var(--app-viewport-height, 100svh) !important;
        background: #111820;
    }

    .final-login-visual {
        min-height: 34svh !important;
        height: 34svh;
        max-height: 320px;
        padding: calc(18px + env(safe-area-inset-top)) 18px 26px !important;
        justify-content: space-between;
    }

    .final-login-visual-top {
        align-items: flex-start;
    }

    .final-login-badge {
        padding: 8px 11px !important;
        max-width: 70vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .login-security-badge {
        font-size: 0;
        width: 34px;
        height: 34px;
        justify-content: center;
        border-radius: 11px;
        background: rgba(17, 24, 32, .44);
        border: 1px solid rgba(255, 255, 255, .15);
    }

    .login-security-badge i {
        font-size: 15px;
    }

    .final-login-visual-bottom h2 {
        font-size: 23px !important;
        margin-bottom: 0 !important;
    }

    .final-login-summary {
        display: none !important;
    }

    .final-login-panel {
        position: relative;
        z-index: 2;
        min-height: 66svh !important;
        margin-top: -18px !important;
        padding: 22px 16px calc(18px + env(safe-area-inset-bottom)) !important;
        border-radius: 24px 24px 0 0 !important;
        background: #f7f8fa !important;
        box-shadow: 0 -18px 44px rgba(0, 0, 0, .18) !important;
        justify-content: flex-start !important;
    }

    .final-login-panel-inner {
        width: 100%;
        max-width: 520px !important;
        margin-inline: auto;
    }

    .login-brand-row {
        margin-bottom: 16px;
    }

    .final-login-logo {
        width: 44px !important;
        height: 44px !important;
        border-radius: 14px !important;
        font-size: 20px !important;
    }

    .login-brand-copy strong {
        font-size: 13.5px;
    }

    .login-brand-copy span {
        font-size: 10.5px;
    }

    .final-login-panel h1 {
        font-size: 22px !important;
    }

    .login-intro {
        margin-bottom: 16px !important;
    }

    .final-login-form .input-group-text,
    .final-login-form .form-control {
        min-height: 50px !important;
        font-size: 16px !important;
    }

    .final-login-form .mb-3 {
        margin-bottom: 12px !important;
    }

    .final-login-submit {
        min-height: 50px !important;
    }

    .app-install-dialog {
        align-items: flex-end;
        padding: 0;
    }

    .app-install-card {
        width: 100%;
        border-radius: 24px 24px 0 0;
        padding: 21px 16px calc(16px + env(safe-area-inset-bottom));
    }
}

@media (max-height: 680px) and (max-width: 991.98px) {
    .final-login-visual {
        height: 28svh;
        min-height: 28svh !important;
    }

    .final-login-panel {
        min-height: 72svh !important;
        padding-top: 17px !important;
    }

    .login-brand-row {
        margin-bottom: 10px;
    }

    .final-login-panel h1 {
        font-size: 20px !important;
    }

    .login-intro,
    .login-footer-note {
        display: none;
    }
}

/* ---------- accessibility / reduced motion ---------- */
:focus-visible {
    outline: 3px solid rgba(139, 104, 66, .26);
    outline-offset: 2px;
}

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

@media print {
    .sidebar-install-card,
    [data-install-app],
    .bottom-tab-bar,
    .mobile-header {
        display: none !important;
    }
}

.brand-icon img,
.final-login-logo img,
#appBootLoader .boot-icon img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: inherit;
}


/* ========================================================================== 
   App Polish V2 — unified dark navigation, permanent active state and loader
   ========================================================================== */

:root {
    --app-bottom-nav-h: 84px;
    --app-loader-bg: #18202a;
    --app-loader-gold: #d7b17b;
}

/* Same visual language at the top and bottom of the mobile app. */
.bottom-tab-bar {
    position: fixed !important;
    inset-inline: 0 !important;
    bottom: 0 !important;
    z-index: 1035 !important;
    isolation: isolate;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    align-items: end !important;
    height: calc(var(--app-bottom-nav-h) + env(safe-area-inset-bottom)) !important;
    padding: 8px 8px calc(7px + env(safe-area-inset-bottom)) !important;
    background:
        radial-gradient(circle at 50% -40%, rgba(215, 177, 123, .17), transparent 35%),
        linear-gradient(180deg, rgba(32, 43, 55, .985), rgba(24, 32, 42, .995)) !important;
    border-top: 1px solid rgba(255, 255, 255, .08) !important;
    box-shadow: 0 -14px 34px rgba(16, 24, 40, .24) !important;
    backdrop-filter: blur(18px) saturate(125%) !important;
    -webkit-backdrop-filter: blur(18px) saturate(125%) !important;
    transform: translateZ(0);
    transition: none !important;
}

.bottom-tab-bar::before {
    content: "";
    position: absolute;
    inset-inline: 14px;
    top: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(215, 177, 123, .45), transparent);
    pointer-events: none;
}

.bottom-tab-item {
    position: relative !important;
    z-index: 2 !important;
    align-self: stretch;
    min-width: 0 !important;
    min-height: 58px !important;
    padding: 7px 3px 5px !important;
    gap: 4px !important;
    color: rgba(230, 235, 240, .58) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 15px !important;
    text-decoration: none !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    opacity: 1 !important;
    transform: none !important;
    transition: background-color .12s ease, color .12s ease !important;
}

.bottom-tab-item::after {
    content: "";
    position: absolute;
    bottom: 1px;
    width: 4px;
    height: 4px;
    border-radius: 999px;
    background: transparent;
}

.bottom-tab-item:hover,
.bottom-tab-item:focus,
.bottom-tab-item:focus-visible {
    color: #fff !important;
    background: rgba(255, 255, 255, .055) !important;
}

.bottom-tab-item:active {
    color: #fff !important;
    background: rgba(255, 255, 255, .10) !important;
    opacity: 1 !important;
    transform: none !important;
}

.bottom-tab-item.active,
.bottom-tab-item[aria-current="page"] {
    color: #fff !important;
    background: rgba(215, 177, 123, .14) !important;
    box-shadow: inset 0 0 0 1px rgba(215, 177, 123, .12) !important;
}

.bottom-tab-item.active::after,
.bottom-tab-item[aria-current="page"]::after {
    background: var(--app-loader-gold);
    box-shadow: 0 0 10px rgba(215, 177, 123, .55);
}

.bottom-tab-icon {
    width: 30px;
    height: 27px;
    display: grid !important;
    place-items: center;
    color: inherit !important;
    font-size: 20px !important;
    line-height: 1 !important;
    opacity: 1 !important;
    transform: none !important;
    transition: color .12s ease !important;
}

.bottom-tab-item.active .bottom-tab-icon,
.bottom-tab-item[aria-current="page"] .bottom-tab-icon {
    color: var(--app-loader-gold) !important;
    transform: none !important;
}

.bottom-tab-label {
    display: block !important;
    color: inherit !important;
    font-size: 10.5px !important;
    font-weight: 800 !important;
    line-height: 1.15 !important;
    white-space: nowrap;
    opacity: 1 !important;
    transform: none !important;
}

/* The active tab is styled on the item itself; the old independent layer caused
   the icon and label to disappear on some iOS view-transition frames. */
.bottom-tab-indicator { display: none !important; }

.bottom-tab-fab-wrap {
    position: relative !important;
    z-index: 4 !important;
    top: -15px !important;
    align-self: start !important;
    width: 100% !important;
    min-height: 70px !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    opacity: 1 !important;
    transform: none !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.bottom-tab-fab {
    width: 58px !important;
    height: 58px !important;
    border-radius: 21px !important;
    color: #fff !important;
    background: linear-gradient(145deg, #ad8453, #795734) !important;
    border: 4px solid #1b2530 !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .30), 0 6px 20px rgba(139, 104, 66, .30) !important;
    font-size: 25px !important;
    opacity: 1 !important;
    transform: none !important;
    transition: filter .12s ease, box-shadow .12s ease !important;
}

.bottom-tab-fab-wrap:active .bottom-tab-fab {
    filter: brightness(1.08);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .30), 0 3px 12px rgba(139, 104, 66, .24) !important;
    transform: none !important;
}

/* One branded loader for first launch, navigation and submit actions. */
.page-loader {
    background:
        radial-gradient(circle at 50% 32%, rgba(215, 177, 123, .14), transparent 30%),
        linear-gradient(180deg, rgba(32, 43, 55, .985), rgba(19, 27, 36, .992)) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .16s ease, visibility .16s ease !important;
}

.page-loader.is-active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: all !important;
}

.page-loader .app-loader-brand {
    animation: app-loader-enter .18s ease-out both;
}

@keyframes app-loader-enter {
    from { opacity: 0; transform: translateY(5px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Old generic box/spinner is intentionally disabled after the branded loader. */
.page-loader-box,
.page-loader-spinner { display: none !important; }

/* PWA update notification */
.pwa-update-bar {
    position: fixed;
    z-index: 3600;
    inset-inline: 14px;
    bottom: calc(var(--app-bottom-nav-h) + env(safe-area-inset-bottom) + 14px);
    display: flex;
    align-items: center;
    gap: 11px;
    width: min(460px, calc(100% - 28px));
    margin-inline: auto;
    padding: 11px 12px;
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 17px;
    color: #fff;
    background: rgba(24, 32, 42, .97);
    box-shadow: 0 18px 45px rgba(16, 24, 40, .25);
    transform: translateY(18px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}

.pwa-update-bar.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pwa-update-bar i { color: var(--app-loader-gold); font-size: 20px; }
.pwa-update-bar-copy { min-width: 0; flex: 1; }
.pwa-update-bar-copy strong { display: block; font-size: 13px; }
.pwa-update-bar-copy small { display: block; color: rgba(255,255,255,.58); font-size: 10.5px; margin-top: 1px; }
.pwa-update-bar button {
    min-height: 36px;
    border: 0;
    border-radius: 11px;
    padding: 0 12px;
    color: #18202a;
    background: #d7b17b;
    font-family: inherit;
    font-size: 11px;
    font-weight: 800;
}

@media (min-width: 992px) {
    .pwa-update-bar { bottom: 22px; }
}

@media (max-width: 991.98px) {
    .content-wrap {
        padding-bottom: calc(var(--app-bottom-nav-h) + env(safe-area-inset-bottom) + 22px) !important;
    }

    html.keyboard-open .bottom-tab-bar {
        display: none !important;
    }
}

@media (max-width: 370px) {
    .bottom-tab-bar { padding-inline: 5px !important; }
    .bottom-tab-label { font-size: 9.8px !important; }
    .bottom-tab-fab { width: 54px !important; height: 54px !important; border-radius: 19px !important; }
}

@media (prefers-reduced-motion: reduce) {
    .page-loader .app-loader-brand,
    .pwa-update-bar { animation: none !important; transition-duration: .01ms !important; }
}

.bottom-tab-item.is-pressing {
    color: #fff !important;
    background: rgba(255, 255, 255, .09) !important;
}

.bottom-tab-item.active.is-pressing,
.bottom-tab-item[aria-current="page"].is-pressing {
    color: #fff !important;
    background: rgba(215, 177, 123, .20) !important;
}

.bottom-tab-fab-wrap.is-pressing .bottom-tab-fab {
    filter: brightness(1.08);
}
