﻿/* ======================================================
   GLOBAL BASE STYLES
   ====================================================== */

html,
body {
    font-family: "Inter Tight", Arial, Helvetica, sans-serif;
    font-size: 0.92rem;
    font-weight: 400;
    margin: 0;
}

/* Links */
a,
.btn-link {
    color: #006bb7;
}

    /* Focus ring consistency (Bootstrap override) */
    .btn:focus,
    .btn:active:focus,
    .btn-link.nav-link:focus,
    .form-control:focus,
    .form-check-input:focus {
        box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.25rem #258cfb;
    }

/* ======================================================
   FORMS & VALIDATION
   ====================================================== */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid,
.validation-message {
    outline: 1px solid #e50000;
    color: #e50000;
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

/* Floating labels */
.form-floating > .form-control::placeholder,
.form-floating > .form-control-plaintext::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control:focus::placeholder,
.form-floating > .form-control-plaintext:focus::placeholder {
    text-align: start;
}

/* ======================================================
   PAGE LAYOUT STRUCTURE
   ====================================================== */

/*#layout {
    display: flex;
    height: 100vh;
    overflow: visible;*/ /* allow dropdowns */
/*}*/

#layout {
    position: relative;
    height: 100vh;
    overflow: visible;
}

/* ======================================================
   SIDEBAR (slides, never squashes)
   ====================================================== */

/*#sidenav {
    position: fixed;
    top: 0;
    left: 0;
    width: 170px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #f4f6f8;
    transform: translateX(-170px);
    transition: transform .3s ease;
    overflow: hidden;
}*/

#sidenav {
    position: fixed;
    top: 0;
    left: 0;
    width: 170px;
    height: 100vh;
    z-index: 2000;
    transform: translateX(-170px);
    transition: transform .3s ease;
    display: flex;
    flex-direction: column;
    background-color: #f4f6f8;
    overflow: hidden;
}

    #sidenav.expanded {
        transform: translateX(0);
    }

    /* Prevent children from forcing width */
    #sidenav * {
        max-width: 100%;
    }

/* ======================================================
   MAIN CONTENT (moves right)
   ====================================================== */

/*#main {
    margin-left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    overflow-y: auto;
    overflow-x: visible;
    position:relative;
    transition: margin-left .3s ease, width .3s ease;
}*/

#main {
    position: relative;
    width: 100%;
    height: 100vh;
    margin-left: 0;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    overflow: hidden;    
    transition: margin-left .3s ease, width .3s ease;
}

/* ======================================================
   DESKTOP ONLY
   Push content right when sidebar is expanded
   ====================================================== */

@media (min-width: 768px) {
    #sidenav.expanded ~ #main {
        margin-left: 170px;
        width: calc(100% - 170px);
    }
}

/* ======================================================
   MOBILE ONLY
   Sidebar overlays content
   ====================================================== */

@media (max-width: 767.98px) {
    #sidenav {
        z-index: 3000;
    }

    #main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    #sidenav.expanded ~ #main {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/*#sidenav.expanded ~ #main {
    margin-left: 170px;
    width: calc(100% - 170px);
}
*/
#main .content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: visible;
    padding-top: 6px;
}

/* ======================================================
   SIDEBAR HEADER
   ====================================================== */

#sidenav .heading {
    min-height: 100px;
    max-height: 120px;
    padding: 0.85rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    position: sticky;
    top: 0;
    z-index: 3;
}



    /* Sidebar header logo */
    #sidenav .heading .topbar-logo {
        width: 100px;

        height: auto;
        display: block;
        margin-bottom: 4px;
    }

    


.footer-logo {
    max-width: 65px; /* pick the size you want */
    width: 651px;
    height: auto; /* preserves aspect ratio */
}



/* ======================================================
   SIDEBAR NAVIGATION
   ====================================================== */

#sidenav .nav-scrollable {
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: 0.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 7px 0 0;
    /*scrollbar-width: none;*/
    will-change: transform;
    contain: paint;
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: #2e4759 transparent;
}

  /*  #sidenav .nav-scrollable::-webkit-scrollbar {
        display: none;
    }*/

    /* Chrome / Edge / Safari */ /*Thin and purple*/
    #sidenav .nav-scrollable::-webkit-scrollbar {
        width: 6px; /* thickness */
    }

    #sidenav .nav-scrollable::-webkit-scrollbar-track {
        background: transparent; /* track color */
    }

    #sidenav .nav-scrollable::-webkit-scrollbar-thumb {
        background-color: #2e4759; /* purple */
        border-radius: 10px;
    }

        #sidenav .nav-scrollable::-webkit-scrollbar-thumb:hover {
            background-color: rebeccapurple; /* darker on hover */
        }


#sidenav .nav-item {
    width: 100%;
    margin: 2px 0;
}

#sidenav .nav-link {
    width: 100%;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 450;
    line-height: 1;
    border: 1px solid rgba(222,222,222,0.45);
    border-radius: 5px;
    color: #333;
    background: rgba(252,252,252,0.35);
    transition: background-color .15s ease, color .15s ease;
}

    #sidenav .nav-link i {
        font-size: 1rem;
        line-height: 1;
    }

    /* Hover */
    #sidenav .nav-link:hover,
    #sidenav .nav-link:hover i {
        color: #2F7A9C;
    }

    #sidenav .nav-link:hover {
        background: rgba(255,255,255,0.5);
    }

    /* Active */
    #sidenav .nav-link.active {
        background: rgba(123,89,201,0.02);
        border: 1px solid rgba(123,89,201,0.02);
        color: #2e4759;
    }

        #sidenav .nav-link.active i {
            color: #2e4759;
        }

        #sidenav .nav-link.active:hover {
            color: #2e4759;
            border-color: rgba(123,89,201,0.05);
        }

    #sidenav .nav-link:hover {
        color: #2F7A9C;
        border-color: rgba(58, 143, 183, 0.15);
    }

/* ======================================================
   SIDEBAR FOOTER
   ====================================================== */

#sidenav .sidebar-footer {
    
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding-bottom:10px;
}


    #sidenav .sidebar-footer a {
        font-size: 0.6rem;
        font-weight: 600;
        color: #333;
        width: 100%;
        text-decoration: none;
        text-align: center;
        display: block;
        line-height: 1.4;
    }

/* ======================================================
   TOPBAR
   ====================================================== */

#main-topbar {
    position: sticky;
    top: 0;
    min-height: 100px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    background: linear-gradient(90deg, #f4f5f7 0%, #f8f9fa 50%, #f4f5f7 100%);
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    z-index: 1100;
}

    #main-topbar .ms-auto {
        display: flex;
        align-items: center;        
        gap: 6px;
    }

    #main-topbar .topbar-link {
        margin-left: 0;
        font-size: 0.9rem;
        font-weight: 450;
        color: #333;
        text-decoration: none;
    }

        #main-topbar .topbar-link:hover {
            color: #2F7A9C;
        }

    #main-topbar .topbar-separator {
        color: #9c9c9c;
        padding-left: 5px;
        padding-right: 5px;
    }

/* Toggle & pin buttons */
.topbar-controls {
    margin-left: 0px;
    margin-top: 3px;
    display: flex;
    font-size: 1.5rem;
}

    .topbar-controls button {
        background: none;
        border: none;
        color: #333;
        cursor: pointer;
    }

        .topbar-controls button:hover {
            color: #2F7A9C;
        }

/* ======================================================
   TABLES & DRAG SCROLL
   ====================================================== */

.aff-table-escape {
    position: relative;
    overflow: visible;
}

.drag-scroll-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    cursor: grab;
}

    .drag-scroll-wrapper:active {
        cursor: grabbing;
    }

.aff-grid-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.92rem;
}

    .aff-grid-table thead th {
        background-color: #f3eefb;
        padding: 10px 14px;
        font-weight: 600;
        border-bottom: 2px solid #dee2e6;
    }

    .aff-grid-table td {
        padding: 8px 14px;
        white-space: nowrap;
        border: 1px dashed rgba(0,0,0,0.05);
    }

.aff-row-selected {
    background-color: #e7f1ff;
}

/* ======================================================
   CUSTOM BUTTONS (DESIGN SYSTEM)
   ====================================================== */


/* Light cerulean */
.btn-cerulean-light {
    background-color: #3A8FB7; /* soft cerulean */
    border-color: #2F7A9C;
    color: #fff;
}

    .btn-cerulean-light:hover {
        background-color: #347FA3;
        border-color: #296B88;
        color: #fff;
    }

    .btn-cerulean-light:active,
    .btn-cerulean-light:focus {
        background-color: #2E708F;
        border-color: #255E78;
        box-shadow: 0 0 0 .25rem rgba(58, 143, 183, .35);
        color: #fff;
    }

/* Dark cerulean */
.btn-cerulean-dark {
    background-color: #1F5F73; /* deep cerulean / blue-green */
    border-color: #184E5E;
    color: #fff;
}

    .btn-cerulean-dark:hover {
        background-color: #1B5567;
        border-color: #144652;
        color: #fff;
    }

    .btn-cerulean-dark:active,
    .btn-cerulean-dark:focus {
        background-color: #174A5A;
        border-color: #113C48;
        box-shadow: 0 0 0 .25rem rgba(31, 95, 115, .35);
        color: #fff;
    }

/* Lavender */
.btn-lavender {
    background-color: #7A66B3; /* soft lavender */
    border-color: #A493C6;
    color: white;
}

    .btn-lavender:hover {
        background-color: #6F5CA8;
        border-color: #9886BC;
        color: white;
    }

    .btn-lavender:active,
    .btn-lavender:focus {
        background-color: #A292CC;
        border-color: #8B7AB5;
        box-shadow: 0 0 0 .25rem rgba(184, 167, 217, .4);
        color: #2E2A3A;
    }




.btn-blue {
    background-color: #1B6EC2;
    border-color: #155A9E;
    color: #fff;
}

.btn-grey {
    background-color: #6C757D;
    border-color: #565E64;
    color: #fff;
}

.btn-red {
    background-color: #DC3545;
    border-color: #B02A37;
    color: #fff;
}

.btn-green {
    background-color: #2F7A9C;
    border-color: #255E78;
    color: #fff;
}

.btn-gold {
    background-color: #D4AF37;
    border-color: #B8962E;
    color: #fff;
    font-weight: 300;
}

/* Hover states */
.btn-purple:hover {
    background-color: #6d4fb8;
    border-color: #5c3da4;
    color: white;
}

.btn-blue:hover {
    background-color: #1861AC;
    border-color: #124A82;
}

.btn-grey:hover {
    background-color: #5A6268;
    border-color: #4A5156;
}

.btn-red:hover {
    background-color: #C82333;
    border-color: #8E1F2A;
}

.btn-green:hover {
    background-color: #296B88;
    border-color: #115C38;
}

.btn-gold:hover {
    background-color: #C9A533;
    border-color: #A8831F;
}

/* Focus + active */
.btn-purple:focus,
.btn-purple:active {
    box-shadow: 0 0 0 .25rem rgba(123, 89, 201, .35);
    color:white;
}

.btn.btn-purple {
    /* base */
    --bs-btn-color: #ffffff;
    --bs-btn-bg: #7B59C9;
    --bs-btn-border-color: #6442B0;
    /* hover */
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: #6d4fb8;
    --bs-btn-hover-border-color: #5c3da4;
    /* active */
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: #6d4fb8;
    --bs-btn-active-border-color: #5c3da4;
    /* disabled — THIS WAS MISSING */
    --bs-btn-disabled-color: #ffffff;
    --bs-btn-disabled-bg: #7B59C9;
    --bs-btn-disabled-border-color: #6442B0;
    /* focus ring */
    --bs-btn-focus-shadow-rgb: 123, 89, 201;
}


.btn-blue:focus,
.btn-blue:active {
    box-shadow: 0 0 0 .25rem rgba(27, 110, 194, .35);
}

.btn-grey:focus,
.btn-grey:active {
    box-shadow: 0 0 0 .25rem rgba(108, 117, 125, .35);
}

.btn-red:focus,
.btn-red:active {
    box-shadow: 0 0 0 .25rem rgba(220, 53, 69, .35);
}

.btn-green:focus,
.btn-green:active {
    box-shadow: 0 0 0 .25rem rgba(58, 143, 183, .35);
}

.btn-gold:focus,
.btn-gold:active {
    box-shadow: 0 0 0 .25rem rgba(212, 175, 55, .35);
}

/* Disabled */
.btn:disabled,
.btn.disabled {
    opacity: .65;
    cursor: not-allowed;
    box-shadow: none;
}

/* ======================================================
   ALERTS
   ====================================================== */

.alert-purple {
    background-color: #f0e6ff;
    border: 1px solid #d0b8ff;
    color: #4b0082;
}

.alert-gold {
    background-color: rgba(212, 175, 55, 0.12);
    border: 1px solid rgba(212, 175, 55, 0.35);
    color: #6b5600;
}

.alert-soft {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #333;
}

/* ======================================================
   TOAST / FEEDBACK
   ====================================================== */

.pe-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    pointer-events: none;
}

.pe-toast-content {
    padding: 16px 28px;
    font-size: 1.05rem;
    border-radius: 10px;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    text-align: center;
    min-width: 320px;
    max-width: 90vw;
    font-weight: 600;
}

    .pe-toast-content.ok {
        background-color: #7b3fe4;
    }

    .pe-toast-content.err {
        background-color: #d93025;
    }

/* ======================================================
   BUTTONS AS LINKS (NAV / INLINE ACTIONS)
   ====================================================== */

.btn-as-link {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    width: 100%;
    text-align: left;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

    .btn-as-link:hover {
        text-decoration: underline;
    }

/* ======================================================
   SMALL UI HELPERS
   ====================================================== */

.btn-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
    line-height: 1.25;
    min-height: 40px;
}

.section-header {
    background-color: #f4f4f4;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    padding-top:0.8rem;
}
/* ======================================================
   MODALS — ALWAYS ABOVE TOPBAR
   ====================================================== */

/* Bootstrap modal stack */
.modal {
    z-index: 30000 !important;
}

.modal-backdrop {
    z-index: 29900 !important;
}

/* Safety: modal internals inherit correctly */
.modal-dialog,
.modal-content {
    z-index: 30001 !important;
}

/* ======================================================
   TOPBAR — IMPERSONATION BUTTON
   ====================================================== */

.impersonate-top-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit; /* EXACT same font as topbar text */
    font-size: 0.9rem;
    font-weight: 400;
    color: #d40000; /* strong red */
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    line-height: 1; /* prevents vertical jump */
}


    .impersonate-top-btn:hover {
        color: #b00000; /* darker red on hover */
        text-decoration: underline;
    }

    .impersonate-top-btn:focus {
        outline: none;
        box-shadow: none;
    }
/* ======================================================
   SIDEBAR — IMPERSONATE BUTTON (NAV ITEM)
   ====================================================== */

#sidenav .impersonate-btn {
    display: flex;
    flex-direction: row; /* icon left, text right */
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background-color: #d63c42; /* strong red */
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    font: inherit;
    font-size:0.9rem;
    font-weight: 400;
    line-height: 1.25;
    cursor: pointer;
    text-align: center;
}

    /* icon inside impersonate button */
    #sidenav .impersonate-btn i {
        font-size: 1.1rem;
        line-height: 1;
        color: inherit;
    }

    /* Keep impersonate icon white even on hover */
    #sidenav .impersonate-btn:hover i {
        color: #fff;
    }


    /* hover */
    #sidenav .impersonate-btn:hover {
        background-color: #c5343a;
        color: #ffffff;
    }

    /* focus / keyboard */
    #sidenav .impersonate-btn:focus {
        outline: none;
        box-shadow: 0 0 0 0.2rem rgba(214,60,66,0.35);
    }

/* ======================================================
   DROPDOWN ACTIONS — TOUCH FRIENDLY
   ====================================================== */

/* Dropdown toggle button (the button you click to open it) */
.dropdown-toggle {
    padding: 0.35rem 0.9rem; /* taller hit area */
    line-height: 1.05;
}

.dropdown {
    position: static;
}

/* Dropdown menu items (the actions inside the menu) */
.dropdown-item {
    padding: 0.7rem 1rem; /* ↑ vertical space */
    line-height: 1.3;
    min-height: 25px; /* touch target */
    display: flex;
    align-items: center;
}

/*top bottom padding*/
.dropdown-menu {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    position: absolute;
    z-index:2000;
}


    /* Icons inside dropdown items */
    .dropdown-item i {
        margin-right: 0.5rem;
        font-size: 1rem;
    }

/* ======================================================
   PAGINATION / NAV BUTTONS — TOUCH FRIENDLY
   ====================================================== */

.btn-group .btn.btn-sm {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    min-height: 33px; /* touch comfort */
    line-height: 1.2;
}

/* ======================================================
   BADGES
   ====================================================== */

.badge.bg-purple {
    background-color: #7B59C9; /* same purple as btn-purple */
    color: #ffffff;
}

.badge.bg-orange {
    background-color: #fd7e14; /* orange*/    
    color: #ffffff;
}

/* ==== STATUS COLOR */
.text-red {
    color: red; /* Bootstrap red, without semantics */
}
.text-orange {
    color: #fd7e14;
    font-weight: 600;
}

.text-green {
    color: #2F7A9C;
    font-weight: 600;
}

.aff-grid-table > tbody > tr > td.text-red {
    color: red;
}

.aff-grid-table > tbody > tr > td.text-orange {
    color: #fd7e14;
}

.aff-grid-table > tbody > tr > td.text-green {
    color: #2F7A9C;
}


.text-end-important {
    justify-content: flex-end; /* ← THIS is the real fix */
    text-align: right; /* fallback for non-flex */
}



/* ======================================================
   BOOTSTRAP-COMPATIBLE CUSTOM BUTTON (LAVENDER)
   ====================================================== */

.btn.btn-lavender {
    /* base */
    --bs-btn-color: #ffffff;
    --bs-btn-bg: #7A66B3;
    --bs-btn-border-color: #A493C6;
    /* hover */
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: #6F5CA8;
    --bs-btn-hover-border-color: #9886BC;
    /* active (this is the missing piece) */
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: #6F5CA8;
    --bs-btn-active-border-color: #9886BC;
    /* focus ring */
    --bs-btn-focus-shadow-rgb: 184, 167, 217;
}

.btn.btn-cerulean-light {
    /* base */
    --bs-btn-color: #ffffff;
    --bs-btn-bg: #3A8FB7;
    --bs-btn-border-color: #2F7A9C;
    /* hover */
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: #347FA3;
    --bs-btn-hover-border-color: #296B88;
    /* active */
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: #2E708F;
    --bs-btn-active-border-color: #255E78;
    /* focus ring */
    --bs-btn-focus-shadow-rgb: 58, 143, 183;
}
.btn.btn-cerulean-dark {
    /* base */
    --bs-btn-color: #ffffff;
    --bs-btn-bg: #1F5F73;
    --bs-btn-border-color: #184E5E;
    /* hover */
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: #1B5567;
    --bs-btn-hover-border-color: #144652;
    /* active */
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: #174A5A;
    --bs-btn-active-border-color: #113C48;
    /* focus ring */
    --bs-btn-focus-shadow-rgb: 31, 95, 115;
}


#sidenav .sidebar-footer .footer-content {
    width: 100%;
    text-align: center;
    font-size:0.6rem;
    font-weight:600;
}

    #sidenav .sidebar-footer .footer-content .powered-by {
        display: block;
        margin-top: 6px;
    }

    #sidenav .sidebar-footer .footer-content a.dev {
        color: #2e4759;
        font-weight: 600;
        text-decoration: none;
    }

        #sidenav .sidebar-footer .footer-content a.dev:hover {
            text-decoration: underline;
        }


/* Your existing global rule - keep it */
.btn:disabled, .btn.disabled {
    opacity: .65;
    cursor: not-allowed;
    box-shadow: none;
}

/* SPECIFIC override for purple buttons */
.btn.btn-purple:disabled,
.btn.btn-purple.disabled {
    background-color: #7B59C9 !important;
    border-color: #6442B0 !important;
    color: #ffffff !important;
}

/* error msg override*/
.invalid, .validation-message {
    outline: none !important;
    color: #e50000;
}


.badge.bg-cerulean {
    background-color: #2f8fa3;
    color: #ffffff;
}
    .badge.bg-cerulean:hover {
        background-color: #297f91;
    }

/* ===============================
   CHART + LEGEND (FINAL)
   =============================== */

/* Allow legends to escape cards safely */
/* Allow chart legends to overflow without breaking table scrolling */
.chart-block {
    overflow: visible !important;
}

/* Keep Bootstrap card defaults intact */
.card,
.card-body {
    overflow: visible;
}

/* Stack chart → legend → buttons */
.chart-block {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Chart container — controls chart size ONLY */
.chart-wrapper {
    position: relative;
    width: 100%;
    max-width: 220px; /* ← THIS is the missing piece */
    aspect-ratio: 1 / 1;
    margin: 0 auto 12px; /* center chart horizontally */
}


    /* Canvas fills wrapper */
    .chart-wrapper canvas {
        width: 100% !important;
        height: 100% !important;
    }

/* Legend list */
.chart-legend {
    list-style: none;
    padding: 0;
    margin: 0;
}

    /* Legend row */
    .chart-legend li {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        font-size: 0.9rem;
        margin-bottom: 6px;
        line-height: 1.2;
    }

/* Color swatch */
.legend-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Scrollable, CENTERED legend */
.chart-legend-scroll {
    max-height: 220px;
    overflow-y: auto;
    margin: 0 auto 14px auto; /* centers legend block */
    width: fit-content; /* shrink to content width */
}

/* Buttons */
.chart-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Mobile tuning */
@media (max-width: 576px) {
    .chart-wrapper {
        max-height: 240px;
        max-width: 160px;
    }

    .chart-legend-scroll {
        max-height: 160px;
    }
}


/* Normalize checkbox appearance in affiliate grid */
.aff-grid-table .form-check-input {
    opacity: 1 !important;
    filter: none !important;
    background-color: #fff;
    border-color: #6c757d;
}

    /* Checked state — Bootstrap default */
    .aff-grid-table .form-check-input:checked {
        background-color: var(--bs-primary);
        border-color: var(--bs-primary);
    }

    /* Focus ring (keyboard + accessibility) */
    .aff-grid-table .form-check-input:focus {
        box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.25);
    }


.btn.btn-cerulean-light:disabled,
.btn.btn-cerulean-light.disabled {
    background-color: #3A8FB7 !important;
    border-color: #2F7A9C !important;
    color: #ffffff !important;
    opacity: .65;
}
.btn.btn-cerulean-dark:disabled,
.btn.btn-cerulean-dark.disabled {
    background-color: #1F5F73 !important;
    border-color: #184E5E !important;
    color: #ffffff !important;
    opacity: .65;
}
/* ======================================================
   BLOCKING OVERLAY (LOGIN CREATION / LONG TASKS)
   ====================================================== */

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(1px);
    z-index: 40000; /* ABOVE .modal (30000) */
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all; /* BLOCK clicks */
}

.login-overlay-box {
    text-align: center;
    font-weight: 600;
    background: #ffffff;
    padding: 28px 36px;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.18);
    min-width: 280px;
    user-select: none;
}



.modal-dialog {
    max-height: 95vh;
}

.modal-body {
    overflow-y: auto;
}


.btn-outline-purple {
    color: #6f42c1;
    border: 1px solid #6f42c1;
    background-color: transparent;
}

    .btn-outline-purple:hover {
        color: #fff;
        background-color: #6f42c1;
        border-color: #6f42c1;
    }

    .btn-outline-purple:focus,
    .btn-outline-purple.focus {
        box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.25);
    }

    .btn-outline-purple:active,
    .btn-outline-purple.active {
        color: #fff;
        background-color: #5a32a3;
        border-color: #5a32a3;
    }

    .btn-outline-purple:disabled,
    .btn-outline-purple.disabled {
        color: #6f42c1;
        background-color: transparent;
        opacity: 0.65;
    }


#components-reconnect-modal {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.6);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
}

    /* When Blazor activates it */
    #components-reconnect-modal.components-reconnect-show {
        display: flex;
    }

    /* Hide the ugly default text */
    #components-reconnect-modal h5,
    #components-reconnect-modal p,
    #components-reconnect-modal button {
        display: none !important;
    }

    /* Add spinner */
    #components-reconnect-modal::before {
        content: "";
        width: 60px;
        height: 60px;
        border: 6px solid #cfe2ff;
        border-top: 6px solid #0d6efd;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    /* Optional soft glow like old version */
    #components-reconnect-modal::after {
        content: "Reconnecting...";
        position: absolute;
        margin-top: 90px;
        font-weight: 500;
        color: #0d6efd;
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ======================================================
   GLOBAL TABLE STYLING (SOFT NEUTRAL CHARCOAL)
   Applies to all Bootstrap tables (.table)
   ====================================================== */

.card .table-responsive,
.card .drag-scroll-wrapper {
    background: #ffffff;
    border: 1px solid #e3eaee;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

/* Base table */
.table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
    background-color: #ffffff;
    color: #374151; /* soft charcoal */
}

    /* Header */
    .table thead th {
        background-color: #f8fafb;
        color: #4b5563; /* charcoal, not blue */
        font-size: 0.78rem;
        font-weight: 600;
        text-transform: none;
        letter-spacing: 0;
        padding: 10px 14px;
        border-bottom: 1px solid #dde6ea;
        vertical-align: middle;
        white-space: nowrap;
    }

    /* Body cells */
    .table tbody td {
        padding: 12px 14px;
        vertical-align: middle;
        border-bottom: 1px solid #edf2f5;
        color: #374151; /* ensure all cells default to charcoal */
    }

        /* Subject text */
        .table tbody td .fw-semibold,
        .table tbody td strong {
            color: #111827;
        }

    /* Muted text */
    .table .text-muted {
        color: #6b7280 !important;
    }

    /* Links inside tables */
    .table a {
        color: inherit;
        text-decoration: none;
    }

        .table a:hover {
            color: #111827;
            text-decoration: underline;
        }

    /* Zebra striping */
    .table tbody tr:nth-child(even) td {
        background-color: #fcfdfe;
    }

/* Hover */
.table-hover tbody tr:hover td {
    background-color: #f7fafb;
}

/* Remove final border */
.table tbody tr:last-child td {
    border-bottom: none;
}

/* Rounded header corners */
.table thead th:first-child {
    border-top-left-radius: 8px;
}

.table thead th:last-child {
    border-top-right-radius: 8px;
}

/* Buttons */
/* Buttons inside tables */
.table .btn {
    border-radius: 5px;
    font-weight: 500;
    white-space: nowrap; /* prevent wrapping */
}
/* Badges */
.table .badge,
.badge {
    border-radius: 4px;
    padding: 0.22rem 0.45rem;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.2;
}

/* Sticky header */
.table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Scrollbar */
.drag-scroll-wrapper::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.drag-scroll-wrapper::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f7;
    border-radius: 10px;
}

.drag-scroll-wrapper::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
    background: #bfd2db;
    border-radius: 10px;
}

    .drag-scroll-wrapper::-webkit-scrollbar-thumb:hover,
    .table-responsive::-webkit-scrollbar-thumb:hover {
        background: #a7c1cc;
    }


/* ======================================================
   CERULEAN ALERT
   Darker border with soft cerulean background
   ====================================================== */

.alert-cerulean {
    background-color: #eaf6fb; /* very light cerulean */
    border: 1px solid #2F7A9C; /* medium cerulean */
    color: #1F5F73; /* dark cerulean */
}

/* ======================================================
   CERULEAN BADGE
   ====================================================== */

.badge.bg-cerulean {
    background-color: #2F7A9C;
    color: #ffffff;
}

    .badge.bg-cerulean:hover {
        background-color: #296B88;
        color: #ffffff;
    }

/* ======================================================
   CERULEAN BUTTON
   Bootstrap-compatible custom button
   ====================================================== */

.btn.btn-cerulean {
    /* Base */
    --bs-btn-color: #ffffff;
    --bs-btn-bg: #2F7A9C;
    --bs-btn-border-color: #255E78;
    /* Hover */
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: #296B88;
    --bs-btn-hover-border-color: #22566E;
    /* Active */
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: #255E78;
    --bs-btn-active-border-color: #1F4E63;
    /* Disabled */
    --bs-btn-disabled-color: #ffffff;
    --bs-btn-disabled-bg: #2F7A9C;
    --bs-btn-disabled-border-color: #255E78;
    /* Focus ring */
    --bs-btn-focus-shadow-rgb: 47, 122, 156;
}



/* Preserve Bootstrap button text colors inside tables */
.table .btn,
.table .btn strong,
.table .btn span {
    color: inherit !important;
    text-decoration: none;
}

/* Explicit white text for solid buttons */
.table .btn-primary,
.table .btn-secondary,
.table .btn-success,
.table .btn-danger,
.table .btn-warning,
.table .btn-info,
.table .btn-purple,
.table .btn-cerulean,
.table .btn-cerulean-light,
.table .btn-cerulean-dark,
.table .btn-lavender {
    color: #ffffff !important;
}

    .table .btn-primary strong,
    .table .btn-secondary strong,
    .table .btn-success strong,
    .table .btn-danger strong,
    .table .btn-warning strong,
    .table .btn-info strong,
    .table .btn-purple strong,
    .table .btn-cerulean strong,
    .table .btn-cerulean-light strong,
    .table .btn-cerulean-dark strong,
    .table .btn-lavender strong {
        color: #ffffff !important;
    }

.table .btn {
    border-radius: 5px;
    font-weight: 400;
    white-space: nowrap;
}

/* ==========================================
   ACTIONS DROPDOWN BUTTON
   ========================================== */

/* Normal state */
.btn-outline-primary {
    color: #4b5563;
    border-color: #cbd5e1;
    background-color: #ffffff;
}

    /* Hover */
    .btn-outline-primary:hover {
        color: #374151;
        background-color: #f8fafc;
        border-color: #b6c2cd;
    }

    /* Focus, active, and open state */
    .btn-outline-primary:focus,
    .btn-outline-primary:active,
    .btn-outline-primary:active:focus,
    .btn-outline-primary.show,
    .btn-outline-primary.show:focus,
    .dropdown-toggle:focus,
    .dropdown-toggle:active,
    .dropdown-toggle.show {
        color: #374151 !important;
        background-color: #ffffff !important;
        border-color: #b6c2cd !important;
        box-shadow: none !important;
        outline: none !important;
    }

    /* Preserve caret color */
    .btn-outline-primary::after {
        color: inherit;
    }


/* Make dropdown menu text match btn-sm size */
.dropdown-menu {
    font-size: 0.875rem; /* same as Bootstrap btn-sm */
}

.dropdown-item {
    font-size: inherit;
    font-weight: 400;
}

/* Force tables inside drag-scroll wrappers to overflow horizontally */
.drag-scroll-wrapper > .table {
    width: max-content;
    min-width: 100%;
}


/* ==========================================
   UNIVERSAL COMPACT WRAPPING TABLE LAYOUT
   ========================================== */

/* Table should be at least as wide as the container,
   but grow only as needed. */
.drag-scroll-wrapper > .table {
    width: auto;
    min-width: 100%;
    table-layout: auto;
}

/* Compact headers */
.table thead th {
    padding: 8px 10px;
    white-space: nowrap;
}

/* Compact body cells with wrapping by default */
.table tbody td {
    padding: 8px 10px;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    vertical-align: middle;
}

/* Keep inherently short UI elements on one line */
.table .badge,
.table .btn,
.table .dropdown-toggle,
.table td.text-nowrap,
.table th.text-nowrap {
    white-space: nowrap;
}

/* Keep first and last columns compact if they contain IDs/actions */
.table th:first-child,
.table td:first-child,
.table th:last-child,
.table td:last-child {
    width: 1%;
    white-space: nowrap;
}



/* ======================================================
   MOBILE ONLY
   Sidebar opens UNDER the topbar while the topbar
   (including hamburger and pin buttons) is pushed right.
   ====================================================== */
@media (max-width: 767.98px) {

    /* Sidebar sits below the top bar */
    #sidenav {
        top: 100px;
        height: calc(100vh - 100px);
        z-index: 3000;
    }

        /* Hide sidebar logo/header on mobile */
        #sidenav .heading {
            display: none;
        }

        #sidenav .nav-scrollable {
            padding-top: 7px;
        }

    /* NEVER push page content on mobile */
    #main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    #sidenav.expanded ~ #main {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* ======================================================
   MOBILE ONLY
   Hide the pin button and align the hamburger with the
   same left edge as the sidebar navigation items.
   ====================================================== */
@media (max-width: 767.98px) {

    /* Hide the pin button on mobile */
    .topbar-controls button:nth-child(2) {
        display: none;
    }

    /* Sidebar nav items use .px-3 = 1rem horizontal padding.
       Align the hamburger to the same left edge. */
    .topbar-controls {
        width: 170px; /* same as sidebar width */
        display: flex;
        justify-content: flex-start;
        align-items: center;
        margin-top: 0;
        margin-left: 0;
        padding-left: 0; /* no extra indentation */
        box-sizing: border-box;
    }

        /* Remove Bootstrap button padding so the icon starts at
       the exact same left position as the menu items */
        .topbar-controls button:first-child {
            padding-left: 0;
            margin-left: 0;
            transform: none;
        }
}


/* ======================================================
   MOBILE OVERLAY
   Click outside the sidebar to close it
   ====================================================== */

.mobile-nav-overlay {
    display: none;
}

@media (max-width: 767.98px) {
    .mobile-nav-overlay {
        position: fixed;
        top: 100px; /* height of top bar */
        left: 170px; /* width of sidebar */
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.05);
        z-index: 2500; /* above page content */
        display: block;
        pointer-events: auto;
    }
}

.btn-delete {
    color: #dc3545 !important;
    border: 1px solid #dc3545 !important;
    background-color: transparent !important;
}

    .btn-delete:hover,
    .btn-delete:focus,
    .btn-delete:active,
    .btn-delete.active {
        color: #ffffff !important;
        background-color: #dc3545 !important;
        border-color: #dc3545 !important;
    }