:root {
    --primary: #00327d;
    --on-primary: #ffffff;
    --primary-container: #0047ab;
    --on-primary-container: #a5bdff;
    --background: #f9f9ff;
    --on-background: #141b2b;
    --surface: #f9f9ff;
    --on-surface: #141b2b;
    --surface-variant: #dce2f7;
    --on-surface-variant: #434653;
    --outline: #737784;
    --outline-variant: #c3c6d5;
    --primary-fixed: #dae2ff;
    --inverse-surface: #293040;
    --surface-container-lowest: #ffffff;
    --surface-container-low: #f1f3ff;

    /* Dashboard Specific */
    --topbar-height: 70px;
    --sidebar-width: 260px;
    --menu-bg: #ffffff;
    --content-bg: #f5f7fb;
    --menu-item-color: #6c757d;
    --topbar-bg: linear-gradient(135deg, #6379c3 0%, #546ee5 60%);
    --topbar-color: #ffffff;
    --card-bg: #ffffff;
}

/* Dark Mode Overrides */
.dark-theme {
    --background: #0f172a; /* Deeper slate for background */
    --on-background: #f1f5f9;
    --surface: #1e293b;
    --on-surface: #f8fafc;
    --surface-variant: #334155;
    --on-surface-variant: #94a3b8;
    --menu-bg: #1e293b;
    --content-bg: #0f172a;
    --card-bg: #1e293b;
    --menu-item-color: #94a3b8;
    --outline-variant: #334155;
    --primary: #8ab4f8;
    --bs-body-bg: var(--background);
    --bs-body-color: var(--on-background);
    --bs-border-color: var(--outline-variant);
    --bs-heading-color: var(--on-background);
    --bs-form-check-bg: #81848a;
}

/* Global Dark Theme Element Overrides */
.dark-theme body {
    color: var(--on-background) !important;
}

.dark-theme .text-muted {
    color: var(--on-surface-variant) !important;
}

.dark-theme .bg-light,
.dark-theme .card-footer.bg-light {
    background-color: var(--surface-variant) !important;
    color: var(--on-surface) !important;
}

.dark-theme .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--on-surface);
    --bs-table-border-color: var(--outline-variant);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
    color: var(--on-surface) !important;
    border-color: var(--outline-variant) !important;
}

.dark-theme .form-control,
.dark-theme .form-select {
    background-color: var(--surface) !important;
    color: var(--on-surface) !important;
    border-color: var(--outline-variant) !important;
}

.dark-theme .form-control:focus,
.dark-theme .form-select:focus {
    background-color: var(--surface-variant) !important;
    color: var(--on-surface) !important;
    border-color: var(--primary) !important;
}

.dark-theme .form-check-input {
    background-color: #81848a !important;
    border-color: var(--outline-variant) !important;
}

.dark-theme .modal-content {
    background-color: var(--surface) !important;
    color: var(--on-surface) !important;
    border: 1px solid var(--outline-variant) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
}

.dark-theme .dropdown-menu {
    background-color: var(--surface) !important;
    color: var(--on-surface) !important;
    border: 1px solid var(--outline-variant) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
}

.dark-theme .dropdown-item {
    color: var(--on-surface) !important;
}

.dark-theme .dropdown-item:hover {
    background-color: var(--surface-variant) !important;
    color: white !important;
}

.dark-theme .vr {
    background-color: var(--outline) !important;
}

/* ==========================================================================
   Cross-cutting dark-mode visibility fixes
   Many pages ship inline <style> blocks with hardcoded light/grey colours
   (e.g. .btn-light-secondary, .table-action-btn, .modern-input-group, table
   headers). Those emit GLOBAL css, so the rules below centrally override them
   for dark mode instead of editing every page.
   ========================================================================== */

/* Soft / secondary buttons and row action icons: dark grey text on a
   near-transparent background becomes invisible on dark surfaces. */
.dark-theme .btn-light-secondary,
.dark-theme .btn-soft-secondary,
.dark-theme .table-action-btn {
    background: rgba(255, 255, 255, 0.07) !important;
    color: var(--on-surface) !important;
    border-color: var(--outline-variant) !important;
}

.dark-theme .btn-light-secondary:hover,
.dark-theme .btn-soft-secondary:hover,
.dark-theme .table-action-btn:hover {
    background: rgba(255, 255, 255, 0.14) !important;
    color: #ffffff !important;
}

.dark-theme .alert-soft-secondary {
    background-color: rgba(255, 255, 255, 0.06) !important;
    color: var(--on-surface-variant) !important;
}

/* Plain table headers that hardcode a light grey band (#f8f9fa) with muted
   text — re-theme them so headers stay readable on dark tables. */
.dark-theme .table thead th,
.dark-theme .table-borderless-custom thead th {
    background-color: var(--surface-variant) !important;
    color: var(--on-surface-variant) !important;
    border-color: var(--outline-variant) !important;
}

/* Modern input groups hardcode light borders and a #fff focus background,
   which turns inputs white (with light text = invisible) when focused. */
.dark-theme .modern-input-group .input-group-text,
.dark-theme .modern-input-group .form-control,
.dark-theme .modern-input-group .form-select {
    border-color: var(--outline-variant) !important;
}

.dark-theme .modern-input-group .input-group-text {
    background-color: var(--surface-variant) !important;
    color: var(--on-surface-variant) !important;
}

.dark-theme .modern-input-group:focus-within .form-control,
.dark-theme .modern-input-group:focus-within .form-select,
.dark-theme .modern-input-group:focus-within .input-group-text {
    background-color: var(--surface-variant) !important;
    color: var(--on-surface) !important;
}

/* Empty-state placeholder icons (#dee2e6) are jarringly bright on dark. */
.dark-theme .empty-icon {
    color: var(--outline) !important;
}

/* Global UI Overrides for Visibility and Consistency */
.list-group-item {
    background-color: transparent !important;
    color: var(--on-surface) !important;
}

.list-group-item .text-muted {
    color: var(--on-surface-variant) !important;
}

/* Floating search dropdowns (client/account autocomplete) hardcode .bg-white,
   so in dark mode they render a white panel behind light list-item text =
   invisible. Re-theme the panel to a dark surface. */
.dark-theme .list-group.position-absolute,
.dark-theme .list-group.position-absolute.bg-white {
    background-color: var(--surface) !important;
    border: 1px solid var(--outline-variant) !important;
}

.dark-theme .list-group.position-absolute .list-group-item-action:hover,
.dark-theme .list-group.position-absolute .list-group-item-action:focus {
    background-color: var(--surface-variant) !important;
    color: #ffffff !important;
}

/* The light-mode "[data-bs-theme=light] i { color: inherit }" rule makes
   dropdown icons inherit the topbar's white text, washing them out on the
   light menu background. Restore visible colours. These selectors only match
   the user dropdown (.dropdown-item-text, anchor items, danger button) and not
   the notification status dots (which are div.dropdown-item). */
.dropdown-menu .dropdown-item-text i.text-primary,
.dropdown-menu a.dropdown-item i {
    color: var(--primary) !important;
}

.dropdown-menu button.dropdown-item.text-danger i {
    color: #dc3545 !important;
}

.accordion-button {
    color: var(--on-surface) !important;
    /*background-color: var(--surface) !important;*/
    transition: all 0.3s ease;
}

/* Global Tab Styling for High Visibility */
.nav-tabs {
    border-bottom: 1px solid var(--outline-variant);
}

.nav-tabs .nav-link {
    border: none !important;
    background: transparent !important;
    color: var(--on-surface-variant) !important;
    font-weight: 700 !important;
    font-size: 13px;
    padding: 12px 20px;
    opacity: 0.75;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent !important;
}

.nav-tabs .nav-link:hover {
    opacity: 1;
    color: var(--primary) !important;
}

.nav-tabs .nav-link.active {
    color: var(--primary) !important;
    opacity: 1;
    border-bottom-color: var(--primary) !important;
}

.dark-theme .nav-tabs .nav-link {
    color: var(--on-surface) !important;
}

/* Global Form Input Styling */
.form-control,
.form-select {
    background-color: var(--card-bg) !important;
    color: var(--on-surface) !important;
    border: 1px solid var(--outline-variant) !important;
    font-size: 13px !important;
    padding: 0.5rem 0.75rem !important;
    transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(0, 50, 125, 0.1) !important;
}

.dark-theme .form-control,
.dark-theme .form-select {
    background-color: var(--surface-variant) !important;
    border-color: var(--outline) !important;
    color: var(--on-surface) !important;
}

.dark-theme .form-control:focus,
.dark-theme .form-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.15) !important;
}

.dark-theme .form-control::placeholder {
    color: var(--on-surface-variant);
    opacity: 0.6;
}

/* Validation Styling */
.form-control.invalid,
.form-select.invalid {
    border-color: #ef4444 !important;
}

.form-control.valid,
.form-select.valid {
    color: var(--primary) !important;
    /* Brand Blue */
    border-color: var(--primary) !important;
    background-color: rgba(0, 50, 125, 0.02) !important;
}

.form-label {
    color: var(--on-surface-variant);
    font-weight: 600;
}

.dark-theme .form-label {
    color: var(--on-surface);
}

.accordion-button:not(.collapsed) {
    /*background-color: rgba(0, 50, 125, 0.05) !important;*/
    color: var(--primary) !important;
    box-shadow: inset 0 -1px 0 var(--outline-variant);
}

.accordion-button::after {
    filter: var(--on-surface-filter, none);
    transition: transform 0.3s ease;
}

.dark-theme .accordion-button::after {
    filter: invert(1);
}

.accordion-button.collapsed::after {
    transform: rotate(0deg);
}

.accordion-button:not(.collapsed)::after {
    transform: rotate(-180deg);
}

/* DataTables Premium Styling & Visibility Fixes */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_processing,
.dataTables_wrapper .dataTables_paginate {
    color: var(--on-surface) !important;
    font-size: 12px;
    margin-top: 4px;
    margin-bottom: 4px;
}

/* Compact Footer Layout */
.dataTables_wrapper .dataTables_info {
    padding-top: 10px !important;
    font-weight: 500;
    opacity: 0.8;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 8px !important;
}

table.dataTable {
    border-collapse: collapse !important;
    margin-top: 8px !important;
    margin-bottom: 8px !important;
    border: 1px solid var(--outline-variant) !important;
    width: 100% !important;
}

table.dataTable thead th {
    background-color: #f1f3f5 !important;
    color: var(--on-surface-variant) !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    font-size: 12px;
    padding: 6px 12px !important;
    border-bottom: 2px solid var(--primary) !important;
    border-right: 1px solid var(--outline-variant) !important;
}

.dark-theme table.dataTable thead th {
    background-color: var(--surface-variant) !important;
}

/* Fix for double headers when scrollY is enabled */
.dataTables_scrollBody thead tr {
    visibility: collapse !important;
    height: 0 !important;
}

.dataTables_scrollBody thead th {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-top: none !important;
    border-bottom: none !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Align scrollable headers and body */
.dataTables_scrollHead {
    overflow: hidden !important;
    width: 100% !important;
}

.dataTables_scrollBody {
    width: 100% !important;
}

.dataTables_scrollHeadInner,
.dataTables_scrollHeadInner table.dataTable {
    width: 100% !important;
    padding-right: 0 !important;
    margin-right: 0 !important;
}

.dataTables_scrollBody table.dataTable {
    width: 100% !important;
}

table.dataTable tbody tr {
    background-color: var(--card-bg) !important;
}

table.dataTable tbody tr.odd {
    background-color: #dddddd !important;
}

.dark-theme table.dataTable tbody tr.odd {
    background-color: rgba(255, 255, 255, 0.05) !important;
}


table.dataTable tbody td {
    background-color: transparent !important;
    color: var(--on-surface) !important;
    padding: 4px 12px !important;
    border-bottom: 1px solid var(--outline-variant) !important;
    border-right: 1px solid var(--outline-variant) !important;
    vertical-align: middle;
    font-size: 13px !important;
}

.dark-theme table.dataTable tbody tr.odd {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

table.dataTable.hover tbody tr:hover,
table.dataTable.display tbody tr:hover {
    background-color: rgba(0, 50, 125, 0.05) !important;
}

/* Light mode specific visibility for DataTables labels */
body:not(.dark-theme) .dataTables_wrapper .dataTables_length label,
body:not(.dark-theme) .dataTables_wrapper .dataTables_filter label {
    color: #e3e3e3 !important;
    font-weight: 600;
}

/* Pagination controls - Joined Group Style */
.dataTables_wrapper .dataTables_paginate {
    display: flex;
    align-items: center;
    gap: 0 !important;
    border: 1px solid var(--outline-variant) !important;
    border-radius: 6px !important;
    overflow: hidden;
    background: white !important;
    padding: 0 !important;
}

.dark-theme .dataTables_wrapper .dataTables_paginate {
    background: var(--surface) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button,
.dataTables_wrapper .dataTables_paginate ul.pagination,
.dataTables_wrapper .dataTables_paginate li.page-item,
.dataTables_wrapper .dataTables_paginate a.page-link {
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--on-surface) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: none !important;
    min-width: 38px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.dataTables_wrapper .dataTables_paginate a.page-link {
    padding: 6px 12px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button,
.dataTables_wrapper .dataTables_paginate li.page-item {
    border-right: 1px solid var(--outline-variant) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:last-child,
.dataTables_wrapper .dataTables_paginate li.page-item:last-child {
    border-right: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate li.page-item.active a.page-link {
    background: var(--primary) !important;
    color: white !important;
    font-weight: 700 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current):not(.disabled),
.dataTables_wrapper .dataTables_paginate li.page-item:not(.active) a.page-link:hover {
    background: var(--surface-variant) !important;
    color: var(--primary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    color: var(--on-surface-variant) !important;
    opacity: 0.5;
    cursor: default !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.previous,
.dataTables_wrapper .dataTables_paginate .paginate_button.next {
    font-weight: 700 !important;
    font-size: 14px !important;
    background: var(--surface-variant) !important;
}

/* Length Select and Filter Input */
.dataTables_length,
.dataTables_filter {
    margin-bottom: 12px !important;
}

.dataTables_length select,
.dataTables_filter input {
    background-color: var(--surface) !important;
    color: var(--on-surface) !important;
    border: 1px solid var(--outline-variant) !important;
    border-radius: 6px;
    padding: 2px 6px !important;
    font-size: 12px !important;
    outline: none;
    transition: border-color 0.2s;
}

.dataTables_length select:focus,
.dataTables_filter input:focus {
    border-color: var(--primary) !important;
}

/* Export Buttons */
.dt-buttons .btn {
    border-radius: 6px !important;
    padding: 6px 14px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
    margin-right: 5px !important;
}

.dt-buttons .btn:last-child {
    margin-right: 0 !important;
}

.dt-buttons .btn:first-child {
    margin-left: 5px !important;
}

.text-dark {
    color: var(--on-surface-variant) !important;
}

/* DataTables Layout Overrides */
.dt-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 5px;

}

.dt-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.dt-header-right {
    flex-grow: 1;
    display: flex;
    justify-content: flex-end;
}

.dt-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 10px;
    padding: 5px;
}

.dt-header-left .dt-buttons {
    margin: 0 !important;
}

.dt-header-left .dataTables_length {
    margin: 0 !important;
}

.dt-header-right .dataTables_filter {
    margin: 0 !important;
}

.dt-header-right .dataTables_filter input {
    width: 250px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--content-bg);
}

/* Typography Utilities */
.font-9 {
    font-size: 9px !important;
}

.font-10 {
    font-size: 10px !important;
}

.font-11 {
    font-size: 11px !important;
}

.font-12 {
    font-size: 12px !important;
}

.font-13 {
    font-size: 13px !important;
}

.font-14 {
    font-size: 14px !important;
}

.font-15 {
    font-size: 15px !important;
}

.font-16 {
    font-size: 16px !important;
}

.font-18 {
    font-size: 18px !important;
}

.font-20 {
    font-size: 20px !important;
}

.font-22 {
    font-size: 22px !important;
}

.font-24 {
    font-size: 24px !important;
}

.fw-500 {
    font-weight: 500 !important;
}

.fw-600 {
    font-weight: 600 !important;
}

.fw-700 {
    font-weight: 700 !important;
}

.fw-800 {
    font-weight: 800 !important;
}


#wrapper {
    min-height: 100vh;
    width: 100%;
    position: relative;
    background-color: var(--content-bg);
    color: var(--on-background);
    transition: background-color 0.3s, color 0.3s;
}

/* ========== Sidebar Structure ========== */
.app-menu {
    width: var(--sidebar-width);
    z-index: 1010;
    background: var(--menu-bg);
    bottom: 0;
    margin-top: 0;
    position: fixed;
    top: 0;
    box-shadow: 0 0 35px 0 rgba(0, 0, 0, 0.1);
    transition: all .3s ease;
    display: flex;
    flex-direction: column;
}

.content-page {
    margin-left: var(--sidebar-width);
    padding: 0 15px 65px 15px;
    min-height: 100vh;
    background-color: transparent;
    transition: all .3s ease;
}

.navbar-custom {
    padding: 0 10px;
    background: var(--topbar-bg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: fixed;
    left: var(--sidebar-width);
    right: 0;
    top: 0;
    height: var(--topbar-height);
    z-index: 1000;
    display: flex;
    align-items: center;
    transition: all .3s ease;
    color: var(--topbar-color);
}

.content {
    padding-top: calc(var(--topbar-height) + 24px);
}

.footer {
    right: 0;
    bottom: 0;
    position: relative;
    padding: 20px;
    border-top: 1px solid var(--outline-variant);
    color: var(--on-surface-variant);
    font-size: 13px;
    transition: all 0.3s ease;
}

/* ========== Responsive Breakpoints ========== */

/* Desktop: Sidebar Collapse */
@media (min-width: 992px) {
    .sidebar-collapsed .app-menu {
        width: 70px;
    }

    .sidebar-collapsed .app-menu .menu-text,
    .sidebar-collapsed .app-menu .menu-header,
    .sidebar-collapsed .app-menu .logo-box img.logo-lg {
        display: none;
    }

    .sidebar-collapsed .content-page {
        margin-left: 70px;
    }

    .sidebar-collapsed .navbar-custom,
    .sidebar-collapsed .footer {
        left: 70px;
        margin-left: 0;
    }

    /* Hover expand when manually collapsed on large screens */
    .sidebar-collapsed .app-menu:hover {
        width: var(--sidebar-width) !important;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
        z-index: 1020;
    }

    .sidebar-collapsed .app-menu:hover .menu-text,
    .sidebar-collapsed .app-menu:hover .menu-header,
    .sidebar-collapsed .app-menu:hover .logo-box img.logo-lg {
        display: block;
    }
}

/* Specific logic for 1024-ish resolution (Small Desktops / Large Tablets) */
@media (min-width: 992px) and (max-width: 1200px) {

    /* Force sidebar to icons only mode by default in this range */
    .app-menu {
        width: 70px !important;
        overflow: hidden;
    }

    .app-menu .menu-text,
    .app-menu .menu-header,
    .app-menu .logo-box img.logo-lg {
        display: none;
    }

    /* Adjust page layout for the narrow sidebar */
    .content-page {
        margin-left: 70px !important;
    }

    .navbar-custom,
    .footer {
        left: 70px !important;
    }

    /* Detached Layout Support in this range */
    .detached-layout .navbar-custom,
    .detached-layout .footer {
        left: 100px !important;
    }

    .detached-layout .content-page {
        margin-left: 85px !important;
    }

    /* Hover effect: Expand sidebar over content */
    .app-menu:hover {
        width: var(--sidebar-width) !important;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
    }

    .app-menu:hover .menu-text,
    .app-menu:hover .menu-header,
    .app-menu:hover .logo-box img.logo-lg {
        display: block;
    }
}



/* Mobile & Tablet: Sidebar Overlay */
@media (max-width: 991px) {
    .app-menu {
        left: calc(-1 * var(--sidebar-width));
    }

    .content-page,
    .navbar-custom,
    .footer {
        margin-left: 0 !important;
        left: 0 !important;
    }

    .sidebar-open .app-menu {
        left: 0;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1005;
        display: none;
    }

    .sidebar-open .sidebar-overlay {
        display: block;
    }
}

/* ========== Detached Layout ========== */
@media (min-width: 992px) {
    .detached-layout .app-menu {
        left: 15px;
        top: 15px;
        bottom: 15px;
        border-radius: 12px;
        height: calc(100vh - 30px);
    }

    .detached-layout .navbar-custom {
        left: calc(var(--sidebar-width) + 30px);
        right: 15px;
        top: 15px;
        border-radius: 12px;
        width: auto;
        margin-left: 0;
    }

    .detached-layout .content-page {
        margin-left: calc(var(--sidebar-width) + 15px);
        padding-top: 15px;
    }

    .sidebar-collapsed.detached-layout .navbar-custom {
        left: 100px;
        margin-left: 0;
    }

    .sidebar-collapsed.detached-layout .content-page {
        margin-left: 85px;
    }

    .sidebar-collapsed.detached-layout .footer {
        left: 100px;
        margin-left: 0;
    }
}

/* ========== Menu Styles ========== */
.logo-box {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
}

.logo-box img {
    max-width: 160px;
    height: auto;
}

.logo-box img.logo-sm {
    max-width: 40px;
    height: auto;
}

.scrollbar {
    flex: 1;
    overflow-y: auto;
}

.menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sub-menu {
    list-style: none;
    padding-left: 1.5rem;
    margin: 0;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: var(--menu-item-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all .2s;
}

.menu-link:hover,
.menu-link.active {
    color: var(--primary);
    background-color: rgba(0, 50, 125, 0.08);
}

.menu-arrow {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.menu-arrow.open {
    transform: rotate(90deg);
}

.menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    margin-right: 12px;
    font-size: 20px;
}

/* ========== Topbar Styles ========== */
.button-toggle-menu {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-item {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 8px;
}

.nav-link {

    text-decoration: none;
    background: none;
    border: none;
}

.dark-theme .nav-link {
    color: white !important;
}

.badge-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: #ff4d4d;
    border: 2px solid #546ee5;
    border-radius: 50%;
}

.bg-white-opacity {
    background: rgba(255, 255, 255, 0.2);
}

.bg-black-opacity {
    background: rgba(0, 0, 0, 0.1);
}

.rounded-circle {
    border-radius: 50% !important;
}

/* Dropdowns */
.dropdown-menu {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--outline-variant);
    border-radius: 8px;
    z-index: 1050;
    margin-top: 5px;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    color: var(--on-surface);
    text-decoration: none;
    border: none;
    background: transparent;
    text-align: left;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--surface-container-low);
    color: var(--primary);
}

/* ========== Streamlined Theme Customizer (Narrower & Less Bulky) ========== */
.offcanvas-settings {
    position: fixed;
    top: 0;
    right: -280px;
    /* Reduced from 320px */
    width: 280px;
    /* Reduced from 320px */
    height: 100vh;
    background: var(--surface);
    z-index: 2000;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    padding: 16px;
    /* Reduced from 24px */
    color: var(--on-surface);
}

.offcanvas-settings.open {
    right: 0;
}

.offcanvas-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1999;
    display: none;
}

.offcanvas-overlay.open {
    display: block;
}

.offcanvas-settings .btn-close {
    padding: 4px;
    font-size: 12px;
}

.offcanvas-settings h4 {
    font-size: 16px;
    /* Smaller title */
    margin: 0;
}

.setting-group {
    margin-bottom: 24px;
    /* Tighter spacing */
}

.setting-group h5 {
    font-size: 10px;
    /* Smaller labels */
    letter-spacing: 0.5px;
}

.theme-toggle-btn {
    padding: 8px 12px;
    /* More compact buttons */
    font-size: 13px;
    border-radius: 6px;
}

/* Shared Page Components */
.card {
    background-color: var(--card-bg) !important;
    color: var(--on-surface) !important;
    border: 1px solid var(--outline-variant);
}

.text-muted {
    color: var(--on-surface-variant) !important;
}

/* ========== Dashboard Premium Styles ========== */
.glass-card {
    background: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    border-radius: 16px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.dark-theme .glass-card {
    background: rgba(36, 43, 61, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.12);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon .material-symbols-outlined {
    font-size: 24px;
}

.stat-label {
    font-size: 13px;
    color: var(--on-surface-variant);
    margin-bottom: 4px;
    font-weight: 500;
}

.stat-value {
    font-size: 20px;
    font-weight: 800;
    margin: 0;
}

.stat-trend {
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.trend-up {
    color: #10b981;
}

.trend-down {
    color: #ef4444;
}

/* Widget Variants */
.border-l-blue {
    border-left: 4px solid #3b82f6;
}

.border-l-green {
    border-left: 4px solid #10b981;
}

.border-l-orange {
    border-left: 4px solid #f59e0b;
}

.border-l-purple {
    border-left: 4px solid #8b5cf6;
}

.bg-soft-blue {
    background: rgba(59, 130, 246, 0.1);
}

.bg-soft-green {
    background: rgba(16, 185, 129, 0.1);
}

.bg-soft-orange {
    background: rgba(245, 158, 11, 0.1);
}

.bg-soft-purple {
    background: rgba(139, 92, 246, 0.1);
}

.bg-soft-red {
    background: rgba(239, 68, 68, 0.1);
}

.bg-soft-info {
    background: rgba(6, 182, 212, 0.1);
}

.text-blue {
    color: #3b82f6 !important;
}

.text-green {
    color: #10b981 !important;
}

.text-orange {
    color: #f59e0b !important;
}

.text-purple {
    color: #8b5cf6 !important;
}

.text-red {
    color: #ef4444 !important;
}

.text-info {
    color: #06b2d2 !important;
}

/* Kanban Styles */
.kanban-column {
    padding: 20px;
    min-height: 500px;
}

.kanban-tasks {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kanban-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--outline-variant);
    cursor: grab;
    transition: all 0.2s;
}

.kanban-card:hover {
    border-color: var(--primary);
}

.card-priority {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 8px;
}

.card-priority.high {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.card-priority.medium {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.card-priority.low {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.sortable-ghost {
    opacity: 0.4;
    border: 2px dashed #3b82f6 !important;
    background: rgba(59, 130, 246, 0.05) !important;
}


.task-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
}

.task-desc {
    font-size: 12px;
    color: var(--on-surface-variant);
    margin-bottom: 0;
}

.task-date {
    font-size: 11px;
    color: var(--on-surface-variant);
    display: flex;
    align-items: center;
    gap: 4px;
}

.member-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
}

.btn-add-task {
    background: rgba(0, 0, 0, 0.03);
    border: 1px dashed var(--outline-variant);
    padding: 12px;
    border-radius: 12px;
    color: var(--on-surface-variant);
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-add-task:hover {
    background: rgba(59, 130, 246, 0.05);
    border-color: #3b82f6;
    color: #3b82f6;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.bg-blue {
    background: #3b82f6;
}

.bg-green {
    background: #10b981;
}

.bg-orange {
    background: #f59e0b;
}

.glass-pill {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(5px);
    border-radius: 50px;
    padding: 4px;
    display: flex;
    gap: 4px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.bg-soft-red {
    background: rgba(239, 68, 68, 0.1) !important;
}

.bg-soft-green {
    background: rgba(16, 185, 129, 0.1) !important;
}

.bg-soft-blue {
    background: rgba(59, 130, 246, 0.1) !important;
}

.bg-soft-orange {
    background: rgba(245, 158, 11, 0.1) !important;
}

.bg-soft-purple {
    background: rgba(139, 92, 246, 0.1) !important;
}

.bg-soft-info {
    background: rgba(6, 182, 212, 0.1) !important;
}

/* Soft Buttons */
.btn-soft-primary {
    background-color: rgba(0, 50, 125, 0.08);
    color: var(--primary);
    border: none;
}

.btn-soft-primary:hover {
    background-color: var(--primary);
    color: white;
}

.btn-soft-info {
    background-color: rgba(6, 182, 212, 0.1);
    color: #06b2d2;
    border: none;
}

.btn-soft-info:hover {
    background-color: #06b2d2;
    color: white;
}

.btn-soft-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: none;
}

.btn-soft-success:hover {
    background-color: #10b981;
    color: white;
}

.btn-soft-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: none;
}

.btn-soft-danger:hover {
    background-color: #ef4444;
    color: white;
}

.btn-soft-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: none;
}

.btn-soft-warning:hover {
    background-color: #f59e0b;
    color: white;
}

div.dataTables_wrapper div.dataTables_length select {
    width: 50% !important;
}

/* Toast Notifications */
.toast-message {
    background: var(--surface);
    color: var(--on-surface);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    min-width: 300px;
    border: 1px solid var(--outline-variant);
    pointer-events: auto;
}

.toast-success {
    border-left: 4px solid #2e7d32;
}

.toast-error {
    border-left: 4px solid #d32f2f;
}

.toast-info {
    border-left: 4px solid var(--primary);
}

.fade-in {
    animation: slideIn 0.3s ease-out forwards;
}

.fade-out {
    animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Registration Tabs Styling */
.registration-tabs .nav-link {
    border: none;
    padding: 1.25rem;
    color: var(--on-surface-variant);
    font-weight: 600;
    transition: all 0.2s;
    border-bottom: 2px solid transparent !important;
    opacity: 0.7;
    background: transparent !important;
}

.registration-tabs .nav-link.active {
    color: var(--primary) !important;
    border-bottom-color: var(--primary) !important;
    opacity: 1;
}

.nepali-font {
    font-family: 'Preeti', 'Kantipur', sans-serif;
    font-size: 20px !important;
}

/* Premium Design System Components */
.modal-backdrop-custom {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-primary-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, #4facfe 100%);
}

.btn-premium-option {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border: 1px solid var(--outline-variant);
    border-radius: 12px;
    background: white;
    transition: all 0.2s ease;
}

.btn-premium-option:hover {
    border-color: var(--primary);
    background: #f0f7ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.glass-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}
/* Member Detail & Profile Components */
.member-photo-container {
    width: 140px;
    height: 140px;
    border-radius: 24px;
    overflow: hidden;
    border: 4px solid white;
    background: white;
}

.member-photo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-label {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--on-surface-variant);
    display: block;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--on-surface);
}

.detail-value-nep {
    font-size: 14px;
    color: var(--on-surface-variant);
}

.bg-soft-primary { background: rgba(0, 50, 125, 0.08); }
.bg-soft-success { background: rgba(34, 197, 94, 0.15); }
.bg-soft-danger { background: rgba(239, 68, 68, 0.15); }
.bg-soft-warning { background: rgba(245, 158, 11, 0.15); }
.bg-soft-info { background: rgba(6, 182, 212, 0.15); }
.bg-soft-light { background: var(--surface-variant); }

.btn-soft-secondary {
    background: var(--surface-variant);
    color: var(--on-surface);
    border: 1px solid var(--outline-variant);
}

.btn-soft-secondary:hover {
    background: var(--outline-variant);
    color: var(--primary);
}

.btn-soft-primary {
    background: rgba(138, 180, 248, 0.1);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-icon-only {
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.manage-pills .nav-link {
    border-radius: 8px;
    color: var(--on-surface-variant);
    padding: 10px 15px;
    transition: all 0.2s;
    border: 1px solid transparent;
    margin-bottom: 4px;
    background: transparent;
}

.manage-pills .nav-link:hover {
    background: var(--surface-variant);
    color: var(--primary);
    border-color: var(--outline-variant);
}

.manage-pills .nav-link.active {
    background: var(--primary) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(0, 50, 125, 0.2);
    border-color: var(--primary);
}

.text-muted-light {
    color: #64748b;
}

/* ========== Global Search Component (gs-) ========== */
.gs-wrapper {
    width: 100%;
    max-width: 480px;
    min-width: 160px;
}

.gs-input-container {
    position: relative;
}

.gs-input-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.6);
    font-size: 18px;
    pointer-events: none;
    z-index: 5;
}

.gs-input {
    width: 100%;
    height: 36px;
    border-radius: 20px !important;
    border: 1px solid rgba(255,255,255,0.25) !important;
    background: rgba(255,255,255,0.15) !important;
    color: #fff !important;
    font-size: 13px !important;
    padding: 0 36px 0 34px !important;
    transition: all 0.2s ease;
    outline: none;
}

.gs-input::placeholder {
    color: rgba(255,255,255,0.6);
}

.gs-input:focus {
    background: rgba(255,255,255,0.25) !important;
    border-color: rgba(255,255,255,0.5) !important;
    box-shadow: none !important;
}

.gs-spinner {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    animation: gs-spin 0.8s linear infinite;
}

@keyframes gs-spin {
    from { transform: translateY(-50%) rotate(0deg); }
    to   { transform: translateY(-50%) rotate(360deg); }
}

/* Dropdown panel */
.gs-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    min-width: 320px;
    background: var(--surface);
    border: 1px solid var(--outline-variant);
    border-radius: 10px;
    z-index: 1200;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

/* Search type tabs */
.gs-tabs {
    display: flex;
    border-bottom: 1px solid var(--outline-variant);
    background: var(--surface-container-low);
}

.gs-tab {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    color: var(--on-surface-variant);
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
    user-select: none;
}

.gs-tab:hover:not(.gs-tab-active) {
    color: var(--primary);
    background: rgba(0,50,125,0.04);
}

.gs-tab-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--surface);
}

/* Scrollable results area */
.gs-results {
    max-height: 380px;
    overflow-y: auto;
    padding: 6px;
}

.gs-empty {
    text-align: center;
    padding: 20px;
    color: var(--on-surface-variant);
    font-size: 13px;
}

/* Member group card */
.gs-member-group {
    border: 1px solid var(--outline-variant);
    border-radius: 6px;
    margin-bottom: 6px;
    overflow: hidden;
}

.gs-member-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--surface-container-low);
    cursor: pointer;
    transition: background 0.15s;
}

.gs-member-header:hover {
    background: var(--surface-variant);
}

.gs-member-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--on-surface);
    flex-grow: 1;
}

.gs-member-cid {
    font-size: 11px;
    color: var(--on-surface-variant);
    margin-left: 4px;
}

.gs-member-link {
    color: var(--primary);
    font-size: 18px;
    opacity: 0.7;
}

/* Account items */
.gs-account-list {
    padding: 4px;
    background: var(--surface);
    border-top: 1px solid var(--outline-variant);
}

.gs-account-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.12s;
    margin-bottom: 2px;
}

.gs-account-item:hover {
    background: var(--surface-container-low);
}

.gs-account-name {
    flex-grow: 1;
    color: var(--on-surface);
    font-size: 12px;
}

.gs-account-no {
    font-size: 11px;
    color: var(--on-surface-variant);
    white-space: nowrap;
}

/* Account type badges */
.gs-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.gs-badge-deposit {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
}

.gs-badge-loan {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

.gs-badge-share {
    background: #f3e5f5;
    color: #7b1fa2;
    border: 1px solid #e1bee7;
}

/* Dark mode badge overrides */
.dark-theme .gs-badge-deposit { background: rgba(25,118,210,0.15); border-color: rgba(25,118,210,0.3); color: #90caf9; }
.dark-theme .gs-badge-loan    { background: rgba(230,81,0,0.15);   border-color: rgba(230,81,0,0.3);   color: #ffcc80; }
.dark-theme .gs-badge-share   { background: rgba(123,31,162,0.15); border-color: rgba(123,31,162,0.3); color: #ce93d8; }

/* Custom scrollbar inside dropdown */
.gs-results.custom-scrollbar::-webkit-scrollbar { width: 5px; }
.gs-results.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.gs-results.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--outline-variant); border-radius: 3px; }
.gs-results.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--outline); }

/* Responsive */
@media (max-width: 768px) {
    .gs-wrapper { max-width: 100%; }
    .gs-dropdown { min-width: 280px; }
    .gs-input { font-size: 12px !important; height: 34px; }
}

/* ========== Logo Visibility (FinacctRKS specific) ========== */

/* Default wide sidebar: show big logo, hide small */
.app-menu .logo-lg { display: block; }
.app-menu .logo-sm { display: none; }

/* Collapsed sidebar (any desktop size): hide big logo, show small */
.sidebar-collapsed .app-menu .logo-lg { display: none !important; }
.sidebar-collapsed .app-menu .logo-sm { display: block !important; }

/* Hover expand when sidebar is collapsed: show big logo again */
.sidebar-collapsed .app-menu:hover .logo-lg { display: block !important; }
.sidebar-collapsed .app-menu:hover .logo-sm { display: none !important; }

/* Auto-icon range (992-1200px): show small logo */
@media (min-width: 992px) and (max-width: 1200px) {
    .app-menu .logo-lg { display: none !important; }
    .app-menu .logo-sm { display: block !important; }

    /* Hover expand in auto-icon range: show big logo again */
    .app-menu:hover .logo-lg { display: block !important; }
    .app-menu:hover .logo-sm { display: none !important; }
}

/* Theme-based logo switching */
[data-bs-theme="dark"] .logo-dark,
[data-bs-theme="light"] .logo-light { display: none !important; }

[data-bs-theme="dark"] .logo-light,
[data-bs-theme="light"] .logo-dark { display: block !important; }

/* Auth pages (login, forgot password, register) carry a single logo variant
   inside .logo-dark; the theme-based switching above (and the conflicting copy
   in modern-redesign.css) would hide it in light mode. Force it visible here.
   Higher specificity than the [data-bs-theme] rules so load order can't undo it. */
[data-bs-theme] .auth-fluid .logo-dark,
[data-bs-theme] .auth-fluid .logo-light { display: block !important; }

/* Ensure small logo respects theme when collapsed */
.sidebar-collapsed .app-menu .logo-dark.logo-sm,
.app-menu .logo-dark.logo-sm { display: none; }

.sidebar-collapsed .app-menu .logo-light.logo-sm,
.app-menu .logo-light.logo-sm { display: none; }

[data-bs-theme="dark"] .sidebar-collapsed .app-menu .logo-light.logo-sm,
[data-bs-theme="dark"] .app-menu .logo-light.logo-sm { display: block !important; }

[data-bs-theme="light"] .sidebar-collapsed .app-menu .logo-dark.logo-sm,
[data-bs-theme="light"] .app-menu .logo-dark.logo-sm { display: block !important; }

/* Hover expand respects theme too */
[data-bs-theme="dark"] .app-menu:hover .logo-dark.logo-lg,
[data-bs-theme="light"] .app-menu:hover .logo-light.logo-lg { display: block !important; }

[data-bs-theme="dark"] .app-menu:hover .logo-light.logo-sm,
[data-bs-theme="light"] .app-menu:hover .logo-dark.logo-sm { display: none !important; }

/* ========== Dark Mode Theme Panel ========== */
html[data-bs-theme="dark"] .offcanvas-overlay {
    background: rgba(0, 0, 0, 0.5);
}

html[data-bs-theme="dark"] .offcanvas-settings {
    background: #1e293b;
    color: #f8fafc;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
}

html[data-bs-theme="dark"] .offcanvas-settings .border-bottom {
    border-color: #334155 !important;
}

html[data-bs-theme="dark"] .offcanvas-settings .btn-close {
    filter: invert(1);
}

html[data-bs-theme="dark"] .theme-toggle-btn {
    color: #f8fafc;
    border-color: #334155;
    background: transparent;
}

html[data-bs-theme="dark"] .theme-toggle-btn:hover {
    background: #334155;
}

html[data-bs-theme="dark"] .theme-toggle-btn.active {
    border-color: #8ab4f8;
    background: rgba(138, 180, 248, 0.05);
}

html[data-bs-theme="dark"] .setting-group h5 {
    color: #94a3b8;
}

/* ===== Native Blazor Table Design System ===== */
.blazor-table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

.blazor-table thead th {
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--on-surface-variant) !important;
    white-space: nowrap;
    padding: 16px 20px !important;
    vertical-align: middle;
    border-bottom: 2px solid rgba(99, 102, 241, 0.15) !important;
    transition: all 0.2s ease;
}

.blazor-table thead th:hover {
    color: var(--primary) !important;
}

/* Header filter inputs */
thead tr.table-light input.form-control-sm {
    height: 32px !important;
    font-size: 0.78rem !important;
    border-radius: 8px !important;
    border: 1px solid var(--outline-variant, #e2e8f0) !important;
    background-color: var(--background, #f8fafc) !important;
    padding: 4px 10px !important;
    transition: all 0.2s ease !important;
}

thead tr.table-light input.form-control-sm:focus {
    background-color: #fff !important;
    border-color: var(--primary, #6366f1) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12) !important;
}

.blazor-table tbody tr {
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: transparent;
}

.blazor-table tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.03) !important;
    transform: scale(1.001);
}

.blazor-table tbody td {
    font-size: .85rem;
    padding: 14px 20px !important;
    vertical-align: middle;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04) !important;
}

/* ===== Card hover effects ===== */
.card {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.card:hover {
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.12);
    transform: translateY(-2px);
}

/* ===== Page Title Box ===== */
.page-title-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0;
}

.page-title-box .page-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--on-surface);
}

.page-title-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    /* Flex parent (above) positions this; wrapping prevents the toolbar from
       overlapping the title when many action buttons don't fit on one line. */
}

.page-title-right .breadcrumb {
    margin: 0;
    padding: 0;
    background: none;
    font-size: 0.8rem;
}

.page-title-right .breadcrumb-item a {
    color: var(--on-surface-variant);
    text-decoration: none;
}

.page-title-right .breadcrumb-item.active {
    color: var(--on-surface-variant);
}

.bg-rgba-primary {
    background: rgba(99, 102, 241, 0.05);
}

.bg-rgba-light {
    background: rgba(0, 0, 0, 0.02);
}

.empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.03);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #adb5bd;
}

.tag-status {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
    text-transform: uppercase;
    letter-spacing: 0.03rem;
}

.badge-type {
    font-size: .72rem !important;
    font-weight: 700 !important;
    padding: 6px 12px !important;
    border-radius: 12px !important;
    text-transform: uppercase;
    letter-spacing: .03em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.badge-cloud {
    background: rgba(20, 184, 166, 0.1) !important;
    color: #0f766e !important;
    border: 1px solid rgba(20, 184, 166, 0.2) !important;
}

.badge-local {
    background: rgba(245, 158, 11, 0.1) !important;
    color: #b45309 !important;
    border: 1px solid rgba(245, 158, 11, 0.2) !important;
}

.ip-tag {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: .78rem;
    background: rgba(99, 102, 241, 0.04) !important;
    padding: 4px 10px !important;
    border-radius: 8px !important;
    color: #4f46e5 !important;
    border: 1px solid rgba(99, 102, 241, 0.08) !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.ip-tag:hover {
    background: rgba(99, 102, 241, 0.08) !important;
    border-color: rgba(99, 102, 241, 0.2) !important;
}

/* Table action buttons */
.table-action-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 10px !important;
    font-size: .92rem !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    text-decoration: none !important;
    cursor: pointer !important;
    border: 1px solid transparent !important;
    background: rgba(0, 0, 0, 0.04) !important;
    color: #495057 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03) !important;
}

.table-action-btn:hover {
    color: #fff !important;
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08) !important;
}

.table-action-btn.btn-edit,
.table-action-btn.btn-primary-soft {
    background: rgba(99, 102, 241, 0.08) !important;
    color: #6366f1 !important;
    border-color: rgba(99, 102, 241, 0.15) !important;
}

.table-action-btn.btn-edit:hover,
.table-action-btn.btn-primary-soft:hover {
    background: #6366f1 !important;
    color: #fff !important;
    border-color: #6366f1 !important;
}

.table-action-btn.btn-view,
.table-action-btn.btn-info-soft {
    background: rgba(6, 182, 212, 0.08) !important;
    color: #06b6d4 !important;
    border-color: rgba(6, 182, 212, 0.15) !important;
}

.table-action-btn.btn-view:hover,
.table-action-btn.btn-info-soft:hover {
    background: #06b6d4 !important;
    color: #fff !important;
    border-color: #06b6d4 !important;
}

.table-action-btn.btn-delete,
.table-action-btn.btn-danger-soft {
    background: rgba(239, 68, 68, 0.08) !important;
    color: #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.15) !important;
}

.table-action-btn.btn-delete:hover,
.table-action-btn.btn-danger-soft:hover {
    background: #ef4444 !important;
    color: #fff !important;
    border-color: #ef4444 !important;
}

.table-action-btn.btn-success-soft {
    background: rgba(16, 196, 105, 0.1) !important;
    color: #10c469 !important;
}

.table-action-btn.btn-warning-soft {
    background: rgba(249, 188, 7, 0.1) !important;
    color: #f9bc07 !important;
}

.table-action-btn.btn-success-soft:hover {
    background: #10c469 !important;
    color: #fff !important;
}

.table-action-btn.btn-warning-soft:hover {
    background: #f9bc07 !important;
    color: #fff !important;
}

/* Pagination - native Blazor */
.pagination .page-link {
    cursor: pointer;
    border: 1px solid var(--outline-variant, #e2e8f0) !important;
    color: var(--on-surface-variant, #64748b) !important;
    background: #fff !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    padding: 0 !important;
    margin: 0 2px !important;
    transition: all 0.2s ease !important;
    box-shadow: none !important;
}

.pagination .page-link:hover:not(:disabled) {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.04) !important;
}

.pagination .page-item.active .page-link {
    background: var(--primary, #6366f1) !important;
    color: #ffffff !important;
    border-color: var(--primary, #6366f1) !important;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.25) !important;
}

.pagination .page-item.disabled .page-link {
    opacity: .5 !important;
    background: var(--background, #f8fafc) !important;
    cursor: not-allowed !important;
}

/* Currency tags */
.currency-text {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: #1e293b;
    font-size: 0.88rem;
}

.currency-symbol {
    font-size: 0.75rem;
    color: #64748b;
    margin-right: 2px;
}

/* Dropdown helpers */
.dropdown-menu .dropdown-item:hover {
    background-color: #f8f9fa;
}

.dropdown-menu .form-check-label {
    cursor: pointer;
}

/* Table filter row */
thead tr.table-light th {
    border-top: none;
    padding-top: 2px !important;
    padding-bottom: 2px !important;
}

/* ===== Stat / Dashboard Cards ===== */
.stat-card {
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .08) !important;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* ===== Dark Theme Overrides for Table System ===== */
.dark-theme .blazor-table thead th {
    background-color: rgba(255, 255, 255, 0.02) !important;
    color: var(--on-surface-variant, #94a3b8) !important;
    border-bottom-color: rgba(138, 180, 248, 0.2) !important;
}

.dark-theme .blazor-table tbody td {
    color: var(--on-surface, #f8fafc) !important;
    border-bottom-color: rgba(255, 255, 255, 0.05) !important;
}

.dark-theme thead tr.table-light input.form-control-sm {
    border-color: var(--outline, #334155) !important;
    background-color: var(--background, #0f172a) !important;
    color: var(--on-surface, #f8fafc) !important;
}

.dark-theme thead tr.table-light input.form-control-sm:focus {
    border-color: var(--primary, #8ab4f8) !important;
    background-color: var(--surface, #1e293b) !important;
}

.dark-theme .ip-tag {
    background: rgba(138, 180, 248, 0.08) !important;
    color: #8ab4f8 !important;
    border-color: rgba(138, 180, 248, 0.15) !important;
}

.dark-theme .pagination .page-link {
    border-color: var(--outline-variant, #334155) !important;
    background-color: var(--surface, #1e293b) !important;
    color: var(--on-surface-variant, #94a3b8) !important;
}

.dark-theme .pagination .page-link:hover:not(:disabled) {
    background: rgba(138, 180, 248, 0.08) !important;
    color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.dark-theme .pagination .page-item.active .page-link {
    background: var(--primary, #8ab4f8) !important;
    color: #0f172a !important;
    border-color: var(--primary, #8ab4f8) !important;
    box-shadow: 0 4px 10px rgba(138, 180, 248, 0.25) !important;
}

.dark-theme .currency-text {
    color: #f8fafc !important;
}

.dark-theme .empty-icon {
    background: rgba(255, 255, 255, 0.05);
    color: var(--on-surface-variant);
}

.dark-theme .stat-icon {
    opacity: 0.9;
}

.dark-theme .bg-rgba-primary {
    background: rgba(138, 180, 248, 0.05);
}

.dark-theme .bg-rgba-light {
    background: rgba(255, 255, 255, 0.02);
}

.dark-theme .badge-cloud {
    background: rgba(26, 188, 156, 0.15) !important;
    color: #34d399 !important;
    border-color: rgba(26, 188, 156, 0.3) !important;
}

.dark-theme .badge-local {
    background: rgba(247, 184, 75, 0.15) !important;
    color: #fcd34d !important;
    border-color: rgba(247, 184, 75, 0.3) !important;
}

/* ===== Keyboard Navigation Focus Indicators ===== */
tr.keyboard-focus {
    background-color: rgba(99, 102, 241, 0.04) !important;
}

tr.keyboard-focus:not(:has(td.keyboard-focus)) {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

td.keyboard-focus {
    outline: 2px solid var(--primary) !important;
    outline-offset: -2px;
    background-color: rgba(99, 102, 241, 0.08) !important;
}

.table-action-btn.keyboard-focus {
    outline: 2px solid var(--primary) !important;
    outline-offset: 2px;
    transform: scale(1.1);
}

/* ===== custom-datatable header overrides ===== */
.custom-datatable thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.02rem;
}

/* ===== native horizontal scroll for responsive tables ===== */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* ===== AI Chat Widget Styles ===== */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1060;
    transition: transform 0.2s, opacity 0.2s;
}
.chat-fab:hover { transform: scale(1.08); }
.chat-fab.hidden { opacity: 0; pointer-events: none; }

.chat-widget-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 1060;
    overflow: hidden;
    border: 1px solid var(--outline-variant);
}
.chat-widget-panel.minimized { height: auto; }

.chat-widget-header {
    background: var(--primary);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    background: var(--background);
    min-height: 0;
}
.chat-message { margin-bottom: 12px; }
.chat-message:last-child { margin-bottom: 0; }

.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    color: var(--on-surface-variant);
    padding: 24px;
}

.chat-message {
    display: flex;
    max-width: 100%;
}
.chat-message.user { justify-content: flex-end; }
.chat-message.assistant { justify-content: flex-start; }

.chat-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 92%;
    word-wrap: break-word;
}
.user-bubble {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.assistant-bubble {
    background: var(--surface);
    color: var(--on-surface);
    border: 1px solid var(--outline-variant);
    border-bottom-left-radius: 4px;
}
.assistant-bubble p { margin-bottom: 0.5em; }
.assistant-bubble p:last-child { margin-bottom: 0; }
.assistant-bubble ul { padding-left: 1.2em; margin-bottom: 0.5em; }
.assistant-bubble code {
    background: rgba(0,0,0,0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 12px;
}

.chat-widget-footer {
    padding: 12px 16px;
    background: var(--surface);
    border-top: 1px solid var(--outline-variant);
    flex-shrink: 0;
}
.chat-input {
    border-radius: 24px !important;
    padding-left: 16px !important;
    font-size: 13px;
    background: var(--background);
    border: 1px solid var(--outline-variant);
}
.chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,50,125,0.1);
}

.btn-soft-primary {
    background: rgba(0,50,125,0.08);
    color: var(--primary);
    border: 1px solid rgba(0,50,125,0.15);
}
.btn-soft-primary:hover {
    background: rgba(0,50,125,0.15);
}
.btn-soft-warning {
    background: rgba(255,193,7,0.12);
    color: #856404;
    border: 1px solid rgba(255,193,7,0.25);
}

/* Highlight animation */
@keyframes ai-pulse-border {
    0%   { box-shadow: 0 0 0 0 rgba(255,193,7,0.7); }
    70%  { box-shadow: 0 0 0 10px rgba(255,193,7,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,193,7,0); }
}
.ai-guide-highlight {
    animation: ai-pulse-border 1.5s ease-out infinite;
    outline: 2px solid #ffc107 !important;
    outline-offset: 2px;
    border-radius: 4px;
    z-index: 1055;
    position: relative;
}

.chat-content-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.chat-reasoning {
    margin-bottom: 12px;
    padding: 10px 14px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}
.chat-reasoning summary {
    font-size: 12px;
    color: var(--on-surface-variant);
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}
.chat-reasoning summary::-webkit-details-marker { display: none; }
.reasoning-text {
    font-size: 12px;
    color: var(--on-surface-variant);
    opacity: 0.85;
    margin-top: 8px;
    white-space: pre-wrap;
    font-style: italic;
    line-height: 1.5;
}

.chat-main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

.chat-history-panel {
    width: 200px;
    border-right: 1px solid var(--outline-variant);
    display: flex;
    flex-direction: column;
    background: var(--surface-container-lowest);
}
.chat-history-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--outline-variant);
    background: var(--surface-container-low);
}
.chat-history-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}
.chat-history-item {
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}
.chat-history-item:hover {
    background: var(--surface-container-highest);
}
.chat-history-item.active {
    background: rgba(0,50,125,0.08);
    border-color: rgba(0,50,125,0.15);
}

@media (max-width: 480px) {
    .chat-widget-panel {
        right: 8px;
        bottom: 8px;
        width: calc(100vw - 16px);
        height: calc(100vh - 16px);
        max-height: none;
    }
}

/* Blazor unhandled-error banner: hidden by default, shown (display:block set inline
   by the Blazor JS runtime) only when a real unhandled exception occurs. */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
