/**
 * MIBT Blazor Application Styles
 * =============================
 * A comprehensive stylesheet for the MIBT Blazor WASM application that defines
 * the visual styling for the entire UI. The stylesheet is organized into logical
 * sections using #region for better navigation and maintenance.
 * 
 * Color Palette:
 * - Primary Blue: #0072ce
 * - Light Blue: #b3d9ff
 * - Background: #FAFAFA
 * - Success Green: #90EE90, #C1FFC1
 * - Error Red: #ffe6e6
 * - Warning/Modified: #E0F5FF
 * 
 * Last updated: June 20, 2025
 */

/* #region Base Elements - Core styling for base HTML elements */

:root {
    /* Canonical app font. Override here to retheme the whole UI. */
    --mibt-font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

html, body {
    font-family: var(--mibt-font);
}

body {
    background-color: #FAFAFA !important;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    overflow: hidden;
}

input[type="text"],
input[type="list"] {
    text-transform: uppercase;
}

hr {
    color: black;
    margin: 0;
}
/* #endregion */

/* #region Utility Classes - Reusable utility classes */
.hidden {
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
}

.visible {
    display: block !important;
}

.disabled {
    filter: invert(100%) grayscale(100%) brightness(50%);
    pointer-events: none;
}

.enabled {
    color: black;
    pointer-events: all;
    cursor: pointer;
}

.close {
    cursor: pointer !important;
    color: red !important;
    background-color: transparent !important;
    border: 0;
}

.bubble {
    display: inline-block;
    margin-right: 5px;
    background-color: lightskyblue;
    color: black;
    text-align: center;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    text-decoration: none;
}
/* #endregion */

/* #region Progress Spinner - Styling for the application's progress indicator */
.progress-container-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0,0,0,0.5);
    z-index: 1500;
}

#progress-container-modal {
    position: fixed !important;
    z-index: 1510;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Width/height come from the inline style on the element so the
       dialog can size itself per-instance. We only enforce a viewport
       cap here so it never spills off-screen. */
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    border-radius: 8px;
    border: 1px solid white;
    background-color: white;
    text-align: center;
}

#progress-container-header {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: ghostwhite;
    font-size: 18pt;
    font-weight: bold;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    overflow: hidden;
    padding: 10px;
    color: #333;
    cursor: pointer;
}

.progress-container-draggable-header {
    background-color: ghostwhite;
    border-bottom: 1px solid #ddd;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

    .progress-container-draggable-header:hover {
        background: linear-gradient(135deg, #e8e8e8 0%, #ddd 100%);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .progress-container-draggable-header:active {
        background: linear-gradient(135deg, #ddd 0%, #ccc 100%);
        box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    }

    .progress-container-draggable-header:hover .material-symbols-outlined {
        opacity: 1;
    }

#progress-container-table {
    width: 100%;
    margin: 10px 0;
}

    #progress-container-table th {
        font-weight: bold;
        text-align: right;
        padding: 5px;
        background-color: white;
        border-bottom: 1px solid #ddd;
    }

    #progress-container-table td {
        text-align: right;
        padding: 5px;
        border-bottom: 1px solid #eee;
    }

#progress-container-button-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background-color: transparent; /* was #f9f9f9 */
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-top: none; /* was 1px solid #ddd */
}

/* Dialog buttons */
#progress-container-toggle {
    padding: 8px 16px;
    background-color: #0072ce;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

    #progress-container-toggle:hover {
        background-color: #005a9e;
    }

    #progress-container-toggle:focus {
        outline: 2px solid #0072ce;
        outline-offset: 2px;
    }

/* Empty rule - can be removed */
#progess-contaner-toggle {
}
/* #endregion */

/* #region Main Layout - Core layout structure for the application */
.main-page {
    height: calc(100vh - 5px) !important;
    width: calc(100vw - 5px) !important;
    border-radius: 15px;
    background-color: #FAFAFA;
}

/* Zoom container - handles centering and overflow */
.zoom-container {
    width: 100%;
    height: calc(100vh - 60px);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-color: #FAFAFA;
}

/* Zoom wrapper - applies the transform and manages actual content size */
.zoom-wrapper {
    transform-origin: top center;
    transition: transform 0.2s ease;
    width: fit-content;
    min-width: 100%;
    display: flex;
    justify-content: center;
}

    /* When zoomed content fits in viewport, keep centered */
    .zoom-wrapper.fits-viewport {
        justify-content: center;
    }

    /* When content overflows viewport, align left to enable proper scrolling */
    .zoom-wrapper.overflows-viewport {
        justify-content: flex-start;
    }

.main-body {
    width: 100% !important;
    height: calc(100vh - 100px);
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    position: relative;
    overflow: visible;
    /* Align content to the right of the sidebar with a few pixels gap */
    margin-left: var(--sb-current);
}

    /* Main page panels (grids) should stack and only the active one should be displayed */
    .main-body > div[id$='-grid'] {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        overflow: visible;
        display: flex;
        flex-direction: column;
    }

/* Pages without sidebars - remove left margin to use full viewport width */
#product-grid,
#material-grid,
#build-grid,
#request-grid,
#view-grid,
#admin-grid,
#detail-grid,
#status-grid {
    margin-left: calc(-1 * var(--sb-current));
}

    /* Ensure non-sidebar pages use full viewport width for their content */
    #request-grid .virtual-grid,
    #view-grid .virtual-grid,
    #admin-grid .virtual-grid,
    #detail-grid .virtual-grid,
    #status-grid .virtual-grid {
        width: 100vw !important;
        max-width: 100vw !important;
       }

    /* Match D365 zebra striping on Request-area VirtualGrid rows only */
    #request-grid .virtual-grid-table-body tr:nth-child(even):not(.row-inserted):not(.virtual-grid-table-row-updated):not(.virtual-grid-table-row-deleted),
    #view-grid .virtual-grid-table-body tr:nth-child(even):not(.row-inserted):not(.virtual-grid-table-row-updated):not(.virtual-grid-table-row-deleted),
    #admin-grid .virtual-grid-table-body tr:nth-child(even):not(.row-inserted):not(.virtual-grid-table-row-updated):not(.virtual-grid-table-row-deleted),
    #detail-grid .virtual-grid-table-body tr:nth-child(even):not(.row-inserted):not(.virtual-grid-table-row-updated):not(.virtual-grid-table-row-deleted) {
        background-color: #f9f9f9;
    }

.virtual-grid-table-body tr:nth-child(odd):not(.row-inserted):not(.virtual-grid-table-row-updated):not(.virtual-grid-table-row-deleted) > td {
    background-color: white;
}

.virtual-grid-table-body tr:nth-child(even):not(.row-inserted):not(.virtual-grid-table-row-updated):not(.virtual-grid-table-row-deleted) > td {
    background-color: #f9f9f9;
}

#view-grid .virtual-grid-table-body tr:hover:not(.row-inserted):not(.virtual-grid-table-row-updated):not(.virtual-grid-table-row-deleted) > td,
#admin-grid .virtual-grid-table-body tr:hover:not(.row-inserted):not(.virtual-grid-table-row-updated):not(.virtual-grid-table-row-deleted) > td,
#detail-grid .virtual-grid-table-body tr:hover:not(.row-inserted):not(.virtual-grid-table-row-updated):not(.virtual-grid-table-row-deleted) > td {
    background-color: var(--mibt-row-hover, #E0EFFF);    
}

/* Master page has submenu - keep the gap to respect sidebar */
#master-grid {
    margin-left: 0;
}

/* Classification and supplemental pages have submenus - keep the gap */
#classification-grid,
#supplemental-grid {
    margin-left: 0;
}

/* D365 pages have a submenu and no sidebar - push content below the fixed strip */
#d365-grid {
    position: relative;
    margin-top: 40px;
    margin-left: calc(-1 * var(--sb-current)); /* cancel out main-body sidebar offset */
    width: 100vw;
    box-sizing: border-box;
    height: calc(100vh - 100px); /* main-body(100vh-60) minus d365-subnav margin(40) */
    display: flex;
    flex-direction: column;
}

    #d365-grid .request-container {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        flex: 1;
        min-height: 0;
        padding-bottom: 0; /* remove the 80px dead space from the global rule */
        display: flex;
        flex-direction: column;
        overflow: hidden; /* let children (table-wrapper + footer) control scrolling */
    }

    /* .visible sub-tab wrapper must pass height down to its page component */
    #d365-grid .visible {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;    
}

/* Grid content containers for VirtualGrid pages */
#build-grid-content,
#master-grid-content,
#product-grid,
#material-grid {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


.main-header {
    background-color: #0072ce !important;
    font-size: 15pt !important;
    font-weight: bold !important;
    width: 100% !important;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

.loading-header {
    background-color: #0072ce !important;
    font-size: 15pt !important;
    font-weight: bold !important;
    width: 100% !important;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    padding: 0px;
    margin: 0px;
    height: 47px;
}

.main-image {
    width: 170px;
    padding: 0px;
    margin: 0px;
    height: 35px;
    white-space: nowrap;
}

.loading-image {
    height: 45px !important;
    width: 170px;
}

.main-name {
    text-align: left;
    vertical-align: middle;
    color: white;
    width: 100px;
    line-height: 1.1;
    font-size: 15pt; /* MIBT title - larger than the 15pt menu tabs */
    border-left: 2px solid white;
    white-space: nowrap;
    cursor: help;
    position: relative;
    width: 50px;
}

.main-version {
    color: white;
    font-size: 7pt;
}

/* Browser info tooltip */
.browser-info-tooltip {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background-color: white;
    border: 2px solid #0072ce;
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    min-width: 280px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 11pt;
    line-height: 1.5;
    white-space: normal;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.browser-info-title {
    font-weight: bold;
    font-size: 12pt;
    color: #0072ce;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid #0072ce;
    text-align: left;
}

.browser-info-row {
    display: flex;
    justify-content: space-between;
    margin: 4px 0;
    color: #333;
    text-align: left;
}

.browser-info-label {
    font-weight: 600;
    color: #555;
    margin-right: 12px;
    min-width: 80px;
}

.browser-info-value {
    color: #0072ce;
    font-weight: 500;
    text-align: right;
    flex: 1;
}

.browser-info-copy-hint {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
    font-size: 9pt;
    color: #888;
    text-align: center;
    font-style: italic;
}

/* Zoom control */
.zoom-control {
    text-align: center;
    vertical-align: middle;
    padding: 0 10px;
    white-space: nowrap;
}

.zoom-btn {
    background-color: #0072ce;
    color: white;
    border: 1px solid white;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

    .zoom-btn:hover {
        background-color: #005a9e;
    }

    .zoom-btn:active {
        background-color: #004578;
    }

.zoom-level {
    display: inline-block;
    color: white;
    font-size: 11pt;
    font-weight: bold;
    min-width: 45px;
    text-align: center;
    margin: 0 4px;
}

.zoom-reset {
    background-color: #0072ce;
    color: white;
    border: 1px solid white;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    margin-left: 4px;
}

    .zoom-reset:hover {
        background-color: #005a9e;
    }

    .zoom-reset:active {
        background-color: #004578;
    }

/* Logo refresh tooltip */
.logo-refresh-tooltip {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(calc(-50% + 5px));
    margin-top: 8px;
    background-color: white;
    border: 2px solid #0072ce;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    min-width: 180px;
    text-align: center;
    white-space: nowrap;
    animation: fadeIn 0.2s ease-in;
}

    .logo-refresh-tooltip::before {
        content: '';
        position: absolute;
        top: -8px;
        left: 50%;
        transform: translateX(calc(-50% + 5px));
        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-bottom: 8px solid #0072ce;
    }

.logo-refresh-icon {
    font-size: 24pt;
    margin-bottom: 6px;
    animation: rotate 2s linear infinite;
}

.logo-refresh-text {
    font-weight: 600;
    font-size: 11pt;
    color: #0072ce;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.main-nav {
    font-size: 14pt;
    display: flex;
    justify-content: center; /* Centers content horizontally */
}
/* #endregion */

/* #region Main Menu - Top navigation menu styling */
.main-menu {
    text-align: center !important;
    vertical-align: middle !important;
    width: auto;
    color: white;
    white-space: nowrap;
    /* Use normal line-height so child buttons truly center vertically in the row.
       A large line-height on the <td> shifts inline-block buttons downward because
       vertical-align:middle aligns to the parent font's x-height, not the line box. */
    line-height: normal !important;
}

.main-menu-table {
    margin: 0 auto; /* Center the table horizontally */
}

.main-menu-choice {
    padding: 5px 10px;
    display: inline-block;
}

.main-menu button {
    background-color: #0072ce !important;
    cursor: pointer !important;
    color: white !important;
    border: 0;
    font-weight: bold;
    display: inline-block;
    margin: 0 5px;
    padding: 6px 10px; /* symmetric top/bottom so tabs are visually centered */
    line-height: 1 !important;
    vertical-align: middle !important;
    height: auto !important;
    max-height: 40px !important;
}

    .main-menu button:hover {
        cursor: pointer !important;
        background-color: lightgray !important;
        border-radius: 5px !important;
        color: white !important;
        display: inline-block;
    }

    .main-menu button:focus {
        cursor: pointer !important;
    }

    .main-menu button.selected {
        background-color: #0072ce !important;
        box-shadow: inset 0 -3px 0 0 white;
        border-radius: 0 !important;
        color: white !important;
    }

.main-icons {
    width: 270px;
    white-space: nowrap;
    height: 50px !important;
    max-height: 50px !important;
    overflow: hidden !important;
}

    .main-icons a {
        color: white;
    }

    .main-icons table {
        height: 50px !important;
        max-height: 50px !important;
    }

    .main-icons tr {
        height: 50px !important;
        max-height: 50px !important;
    }

    .main-icons td {
        height: 50px !important;
        max-height: 50px !important;
        vertical-align: middle !important;
    }

    .main-icons span {
        line-height: normal !important;
        vertical-align: middle !important;
    }
/* #endregion */

/* #region Sheets Navigation - Tab-like navigation for content sheets */
.main-sheets {
    display: flex;
    width: 100vw !important;
    height: 40px;
    white-space: nowrap !important;
    background-color: #b3d9ff !important;
    color: #333333 !important;
    font-size: 13pt !important;
    font-weight: bold !important;
    justify-content: center;
    vertical-align: bottom;
}

.main-sheets-progress {
    display: flex;
    width: 100vw;
    height: 40px;
    white-space: nowrap !important;
    background-color: #b3d9ff !important;
    color: #333333 !important;
    font-size: 13pt !important;
    font-weight: bold !important;
    justify-content: left;
    vertical-align: bottom;
}

/* Add spacing for content below sub menus (when present) */
/* Master, Classification, and Supplemental grid containers - all use same layout */
#master-grid-content,
#classification-grid,
#supplemental-grid {
    position: relative;
    /* Top margin to position below the fixed sub menu at 95px (55 + 40) */
    margin-top: 40px;
    margin-left: 0;
    padding-left: 0;
    padding-top: 0;
    width: 100%;
    box-sizing: border-box;
    min-height: calc(100vh - 95px); /* Ensure it fills remaining space */
}

    /* Virtual grids - use full viewport width minus sidebar */
    #master-grid-content .virtual-grid,
    #classification-grid .virtual-grid,
    #supplemental-grid .virtual-grid {
        align-items: center;
        margin-left: 0;
        margin-top: 0;
        width: calc(100vw - var(--sb-current));
    }

    /* Table containers - center with auto margins */
    #master-grid-content .virtual-grid-table-container,
    #classification-grid .virtual-grid-table-container,
    #supplemental-grid .virtual-grid-table-container {
        margin-left: auto;
        margin-right: auto;
        margin-top: 0;
        /* Don't constrain width - let content wrapper determine size */
    }

    /* Content wrappers - center with auto margins */
    #master-grid-content .virtual-grid-table-content-wrapper,
    #classification-grid .virtual-grid-table-content-wrapper,
    #supplemental-grid .virtual-grid-table-content-wrapper {
        margin-left: auto;
        margin-right: auto;
        margin-top: 0;
    }

    /* Footer bars - full viewport width minus sidebar */
    #master-grid-content .virtual-grid-footer-bar,
    #classification-grid .virtual-grid-footer-bar,
    #supplemental-grid .virtual-grid-footer-bar {
        justify-content: center;
        margin-left: 0;
        margin-top: 0;
        width: calc(100vw - var(--sb-current));
    }

    /* Ensure footer labels aren't truncated */
    #master-grid-content .virtual-grid-footer-row-count,
    #classification-grid .virtual-grid-footer-row-count,
    #supplemental-grid .virtual-grid-footer-row-count {
        min-width: 20ch;
        grid-template-columns: auto minmax(10ch, 10ch);
    }

/* Build grids - no progress bar, just grid content */
/* Build grids - same layout as master/classification/supplemental but no submenu spacing */
#build-grid,
#build-grid-content {
    position: relative;
    margin-top: 0; /* No submenu, so no top margin */
    margin-left: 0;
    padding-left: 0;
    padding-top: 0;
    width: 100%;
    box-sizing: border-box;
    min-height: calc(100vh - 55px); /* Full height minus header only (no submenu) */
}

    /* Build virtual grids - use full viewport width minus sidebar (same as master) */
    #build-grid .virtual-grid,
    #build-grid-content .virtual-grid {
        align-items: center;
        margin-left: 0;
        margin-top: 0;
        width: calc(100vw - var(--sb-current));
    }

    /* Build table containers - center with auto margins (same as master) */
    #build-grid .virtual-grid-table-container,
    #build-grid-content .virtual-grid-table-container {
        margin-left: auto;
        margin-right: auto;
        margin-top: 0;
        /* Don't constrain width - let content wrapper determine size */
    }

    /* Build content wrappers - center with auto margins (same as master) */
    #build-grid .virtual-grid-table-content-wrapper,
    #build-grid-content .virtual-grid-table-content-wrapper {
        margin-left: auto;
        margin-right: auto;
        margin-top: 0;
    }

    /* Build footer bars - full viewport width minus sidebar (same as master) */
    #build-grid .virtual-grid-footer-bar,
    #build-grid-content .virtual-grid-footer-bar {
        justify-content: center;
        margin-left: 0;
        margin-top: 0;
        width: calc(100vw - var(--sb-current));
    }

    /* Ensure footer labels aren't truncated in build pages */
    #build-grid .virtual-grid-footer-row-count,
    #build-grid-content .virtual-grid-footer-row-count {
        min-width: 20ch;
        grid-template-columns: auto minmax(10ch, 10ch);
    }

.main-sheets-progress-button {
    border-radius: 15px;
    background-color: #32CD32;
    border: 1px solid lightgrey;
    color: white;
    height: 30px;
    width: 30px;
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
}

    .main-sheets-progress-button:focus {
        outline: none;
        box-shadow: 0 0 0 3px #ffffff, 0 0 0 1px #000000 inset; /* white outer border, black inner border */
    }

.main-sheets-progress-select {
    border-radius: 15px;
    background-color: white;
    border: 1px solid lightgrey;
    color: #333333;
    height: 30px;
    padding: 0 12px;
    font-size: 13pt;
    font-weight: bold;
}

    .main-sheets-progress-select:focus {
        outline: none;
        box-shadow: 0 0 0 3px #ffffff, 0 0 0 1px #000000 inset;
    }

.main-sheets-table {
    width: 100% !important;
    max-width: calc(100vw - 10px) !important;
}

    .main-sheets-table td:last-child {
        width: 40px !important;
    }

.main-sheets-table-sheets {
    vertical-align: bottom;
    width: 100% !important;
    text-align: center;
    padding: 0px;
    margin: 0px;
}

.main-sheets-table-sheets-div {
    width: 100%;
    overflow: hidden;
}

.main-sheets-table-scroll {
    width: 40px;
}

.main-sheets .check-mark {
    color: darkgreen;
    font-size: 12pt;
    visibility: hidden;
    vertical-align: bottom;
}

.main-sheets .check-mark-checked {
    color: darkgreen;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets .check-mark-checked-issues {
    color: red;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets .check-mark-checked-warnings {
    color: #808000;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets .sheet {
    white-space: nowrap !important;
    padding: 0 10px !important;
    font-size: 13pt !important;
    font-weight: bold !important;
    color: #333333 !important;
    cursor: pointer !important;
    border-radius: 5px;
}

.main-sheets .sheet-selected {
    position: relative;
    background-color: white;
    border-radius: 8px 8px 0 0;
}

    .main-sheets .sheet-selected::before {
        content: "";
        position: absolute;
        top: -10px;
        left: -6px;
        right: -6px;
        bottom: 0;
        background: white;
        /* soften curve (NOT full +10) */
        border-radius: 14px 14px 0 0;
        z-index: -1;
    }


.main-sheets .sheet:hover {
    position: relative;
    background-color: #f0f0f0 !important;
    border-radius: 8px 8px 0 0;
    font-size: 13pt !important;
    color: #333333 !important;
    cursor: pointer !important;
    color: black;
}

    .main-sheets .sheet:hover::before {
        content: "";
        position: absolute;
        top: -10px;
        left: -6px;
        right: -6px;
        bottom: 0;
        background-color: #f0f0f0 !important;
        /* soften curve (NOT full +10) */
        border-radius: 14px 14px 0 0;
        z-index: -1;
    }


.main-sheets .sheet-spacer {
    display: flex;
    white-space: nowrap;
    padding-left: 2px;
    padding-right: 2px;
}

.main-sheets-drop .check-mark {
    color: darkgreen;
    font-size: 12pt;
    visibility: hidden;
    vertical-align: bottom;
}

.main-sheets-drop .check-mark-checked {
    color: darkgreen;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets-drop .check-mark-checked-issues {
    color: red;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets-drop .check-mark-checked-warnings {
    color: #808000;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets-drop .sheet {
    white-space: nowrap !important;
    padding: 0 !important;
    font-size: 13pt !important;
    font-weight: bold !important;
    color: #333333 !important;
    cursor: pointer !important;
    border-radius: 5px;
}

    /*.main-sheets-drop .sheet-selected {
    white-space: nowrap !important;
    padding: 0 !important;
    font-weight: bold !important;
    border-bottom: 6px solid white !important;
}
*/
    .main-sheets-drop .sheet:hover {
        white-space: nowrap !important;
        background-color: white !important;
        padding: 0 !important;
        font-size: 13pt !important;
        font-weight: bold !important;
        color: #333333 !important;
        cursor: pointer !important;
    }

@media (max-width: 1500px) {

    /* Main menu: left-align in hamburger mode */
    .main-menu {
        text-align: left !important;
    }

    .main-sheets-table-sheets {
        text-align: left;
        width: auto;
    }

    .main-sheets-table-sheets-div {
        display: inline-block;
        width: auto;
    }

    /* NOTE: CSS dropdown rules removed - JavaScript handles dropdown at this breakpoint */
    /* The setupDropdownMasterMenu() function in menu.js creates the dropdown structure */
}

/* #endregion */
/* #region Page Structure - Content page layout components */
.page-body {
    max-width: 100vw !important;
}

.page-content {
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
}
/* #endregion */

.under-construction {
}

    .under-construction div:nth-of-type(2) {
        display: flex;
        flex-direction: column; /* Stack items vertically */
        justify-content: center; /* Center vertically */
        align-items: center; /* Center horizontally */
    }

        .under-construction div:nth-of-type(2) img {
            width: 40%;
        }

.icon-container {
    white-space: nowrap;
}

.icon {
    font-size: 24px;
    width: 25px;
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border-radius: 3px;
}

    .icon:hover {
        background-color: rgba(255, 255, 255, 0.2);
        transform: scale(1.1);
    }

/* Icon color definitions optimized for blue toolbar background (#0072ce) */

.save {
    color: #FFFFFF; /* white for save icon - good contrast */
    background-color: rgba(255, 255, 255, 0.1); /* subtle white background */
}

    .save:hover {
        color: #4CAF50; /* green on hover */
        background-color: rgba(76, 175, 80, 0.2); /* light green background on hover */
    }

.save-as {
    color: #FFD700; /* gold color for better contrast than previous yellow */
    background-color: rgba(255, 215, 0, 0.15); /* subtle gold background */
}

    .save-as:hover {
        color: #FFC107; /* amber on hover */
        background-color: rgba(255, 193, 7, 0.25); /* amber background on hover */
    }

.open {
    color: #FF9800; /* orange for folder open - good contrast */
    background-color: rgba(255, 152, 0, 0.15); /* subtle orange background */
}

    .open:hover {
        color: #F57C00; /* darker orange on hover */
        background-color: rgba(255, 152, 0, 0.25); /* more prominent orange background */
    }

.excel {
    color: #4CAF50; /* green for Excel theme */
    background-color: rgba(76, 175, 80, 0.15); /* subtle green background */
}

    .excel:hover {
        color: #388E3C; /* darker green on hover */
        background-color: rgba(76, 175, 80, 0.25); /* more prominent green background */
    }

.update-page {
    color: #E3F2FD; /* very light blue - improved from previous */
    background-color: rgba(227, 242, 253, 0.15); /* subtle light blue background */
}

    .update-page:hover {
        color: #BBDEFB; /* medium light blue on hover */
        background-color: rgba(187, 222, 251, 0.25); /* more prominent blue background */
    }

.update-all {
    color: #90CAF9; /* medium blue for better contrast */
    background-color: rgba(144, 202, 249, 0.15); /* subtle blue background */
}

    .update-all:hover {
        color: #64B5F6; /* darker blue on hover */
        background-color: rgba(144, 202, 249, 0.25); /* more prominent blue background */
    }

.update-email {
    color: #FFE082; /* light amber for email theme */
    background-color: rgba(255, 224, 130, 0.15); /* subtle amber background */
}

    .update-email:hover {
        color: #FFCC02; /* darker amber on hover */
        background-color: rgba(255, 204, 2, 0.25); /* more prominent amber background */
    }

.update-silent {
    color: #BDBDBD; /* medium gray for better contrast than light gray */
    background-color: rgba(189, 189, 189, 0.15); /* subtle gray background */
}

    .update-silent:hover {
        color: #9E9E9E; /* darker gray on hover */
        background-color: rgba(158, 158, 158, 0.25); /* more prominent gray background */
    }

.clear {
    color: #F44336; /* material red for clear action */
    background-color: rgba(244, 67, 54, 0.15); /* subtle red background */
}

    .clear:hover {
        color: #D32F2F; /* darker red on hover */
        background-color: rgba(244, 67, 54, 0.25); /* more prominent red background */
    }

.refresh-db {
    color: #E1BEE7; /* lavender - works well with blue background */
    background-color: rgba(225, 190, 231, 0.15); /* subtle lavender background */
}

    .refresh-db:hover {
        color: #CE93D8; /* darker lavender on hover */
        background-color: rgba(206, 147, 216, 0.25); /* more prominent lavender background */
    }

.enter-products {
    color: #FF9800; /* orange for product entry actions */
    background-color: rgba(255, 152, 0, 0.15); /* subtle orange background */
}

    .enter-products:hover {
        color: #F57C00; /* darker orange on hover */
        background-color: rgba(255, 152, 0, 0.25); /* more prominent orange background */
    }

.preview {
    color: #FFE082;
    background-color: rgba(255, 224, 130, 0.15);
}

    .preview:hover {
        color: #FFCC02;
        background-color: rgba(255, 204, 2, 0.25);
    }

.generate {
    color: #FFE082;
    background-color: rgba(255, 224, 130, 0.15);
}

    .generate:hover {
        color: #FFCC02;
        background-color: rgba(255, 204, 2, 0.25);
    }

/* #region Undo/Redo Icons - Styling for undo/redo functionality in main toolbar */
.undo {
    color: #FFB74D; /* light orange for undo action */
    background-color: rgba(255, 183, 77, 0.15); /* subtle orange background */
}

    .undo:hover {
        color: #FF9800; /* medium orange on hover */
        background-color: rgba(255, 152, 0, 0.25); /* more prominent orange background */
    }

    .undo.disabled {
        filter: invert(100%) grayscale(100%) brightness(50%);
        pointer-events: none;
        opacity: 0.5;
    }

.redo {
    color: #81C784; /* light green for redo action */
    background-color: rgba(129, 199, 132, 0.15); /* subtle green background */
}

    .redo:hover {
        color: #4CAF50; /* medium green on hover */
        background-color: rgba(76, 175, 80, 0.25); /* more prominent green background */
    }

    .redo.disabled {
        filter: invert(100%) grayscale(100%) brightness(50%);
        pointer-events: none;
        opacity: 0.5;
    }

/* Undo/Redo dropdown styling */
.main-undo-redo-dropdown {
    position: absolute;
    background: #ffffff;
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    min-width: 300px;
    max-width: 400px;
    display: none;
}

    /* Headbox tooltip (reuses undo/redo dropdown header styling, without the list) */
    .main-undo-redo-dropdown.mibt-icon-headbox {
        min-width: unset;
        max-width: 320px;
        width: max-content;
        pointer-events: auto;
        cursor: pointer;
    }

        .main-undo-redo-dropdown.mibt-icon-headbox .dropdown-header {
            border-bottom: none;
            white-space: normal;
        }

    .main-undo-redo-dropdown .dropdown-header {
        background-color: #B3D9FF;
        border-bottom: 1px solid #ddd;
        padding: 8px 12px;
        font-weight: bold;
        font-size: 14px;
        color: #333;
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;
    }

    .main-undo-redo-dropdown .dropdown-content {
        max-height: 300px;
        overflow-y: auto;
        font-size: 10pt;
        padding: 0;
        background-color: #E0EFFF;
    }

    .main-undo-redo-dropdown .dropdown-item {
        display: block;
        width: 100%;
        text-align: left;
        padding: 8px 12px;
        border: none;
        background-color: #E0EFFF;
        cursor: pointer;
        border-bottom: 1px solid #f0f0f0;
        border-radius: 4px; /* 4px border-radius for consistency */
        transition: background-color 0.2s ease;
    }

        .main-undo-redo-dropdown .dropdown-item:hover {
            background-color: #D1E7FF;
        }

        .main-undo-redo-dropdown .dropdown-item.selected,
        .main-undo-redo-dropdown .dropdown-item.selected:hover {
            background-color: #e3f2fd;
            box-shadow: inset 4px 0 0 #0072ce;
        }

/* Open Saved dropdown: selected item highlight */
.virtual-grid-select-save-as-dropdown .dropdown-item.selected,
.virtual-grid-select-save-as-dropdown .dropdown-item.selected:hover {
    background-color: #D1E7FF;
}

.main-undo-redo-dropdown .dropdown-item:last-child {
    border-bottom: none;
}

.main-undo-redo-dropdown .dropdown-item.disabled {
    color: #999;
    cursor: default;
    font-style: italic;
}

    .main-undo-redo-dropdown .dropdown-item.disabled:hover {
        background-color: transparent;
    }

.main-undo-redo-dropdown .dropdown-item div:first-child {
    font-weight: bold;
    margin-bottom: 2px;
    color: #333;
}

.main-undo-redo-dropdown .dropdown-item div:last-child {
    font-size: 0.9em;
    color: #666;
}

/* Keep dropdown open when hovering */
.main-undo-redo-dropdown:hover {
    display: block !important;
}
/* #endregion */

/* Highlight for updated (yellow) rows in VirtualGrid */
.virtual-grid-table-row-updated {
    background-color: #fff9c4 !important; /* Material yellow 100 */
    transition: background-color 0.3s;
}

    /* Optionally, highlight updated cells as well */
    .virtual-grid-table-row-updated td {
        background-color: #fff9c4 !important;
    }

.auto-select-wrapper {
    position: relative;
    display: inline-block;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding-right: 28px; /* reserve full width for new chevron container */
    box-sizing: border-box;
    width: fit-content;
}

    .auto-select-wrapper input {
        border: 1px solid lightgrey;
        outline: none;
        padding: 8px;
        font-size: 16px;
        border-radius: 4px;
        width: 100%;
        box-sizing: border-box;
        color: #000; /* force black text */
        font-weight: normal; /* semibold */
    }

.chevron {
    position: absolute;
    top: 0; /* full height */
    right: 0; /* flush to wrapper edge */
    bottom: 0; /* stretch */
    transform: none; /* no vertical translate needed */
    display: flex; /* center icon */
    align-items: center;
    justify-content: center;
    width: 28px; /* matches padding-right */
    cursor: pointer;
    font-size: 24px;
    color: #555;
    user-select: none;
    line-height: 1; /* keep icon tight */
}

/* Optional visual separator */
.auto-select-wrapper .chevron {
    border-left: 1px solid #ccc;
}

.auto-select-wrapper input[readonly],
.auto-select-wrapper input:read-only {
    background-color: #f5f5f5; /* lighter grey for readonly to match disabled */
    cursor: default;
}

    .auto-select-wrapper input[readonly] ~ .chevron,
    .auto-select-wrapper input:read-only ~ .chevron {
        background-color: #f5f5f5; /* lighter grey chevron for readonly */
        color: #888;
        cursor: not-allowed;
        pointer-events: none;
    }

    .auto-select-wrapper input:disabled ~ .chevron,
    .auto-select-wrapper input[readonly] ~ .chevron,
    .auto-select-wrapper input:read-only ~ .chevron {
        background-color: #f5f5f5;
        color: #888;
        cursor: not-allowed;
        pointer-events: none;
    }

    /* Never show dropdown if host input is disabled/readonly */
    .auto-select-wrapper input:disabled ~ .auto-select-dropdown,
    .auto-select-wrapper input[readonly] ~ .auto-select-dropdown,
    .auto-select-wrapper input:read-only ~ .auto-select-dropdown {
        display: none !important;
    }

.auto-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #ffffff !important; /* reinforce solid background */
    border: 1px solid #ccc !important; /* reinforce border */
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    padding-left: 8px;
    z-index: 1000;
    isolation: isolate; /* create stacking context to prevent bleed */
    color: #000; /* force black text */
    font-weight: normal; /* semibold */
}

.auto-select-dropdown {
    background: #fff;
    border: 1px solid #ccc;
}

    .auto-select-dropdown ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .auto-select-dropdown li {
        padding: 6px 8px;
        cursor: pointer;
        border: none;
        background: transparent;
        white-space: nowrap;
    }

        /* Hover state - light grey background */
        .auto-select-dropdown li:hover {
            background-color: #d3d3d3;
            border: none;
            outline: none;
        }

        /* Selected state (keyboard navigation) - light grey background */
        .auto-select-dropdown li.selected {
            background-color: #d3d3d3;
            border: none;
            outline: none;
        }

        /* Focused state - light grey background */
        .auto-select-dropdown li:focus {
            background-color: #d3d3d3;
            border: none;
            outline: none;
        }


/***********************************************************
    Sidebar
*/

:root {
    --cell-h: 48px;
    --icon: 32px;
    --pad-x: 6px;
    --pad-gap: 4px;
    --popover-bg: #fff;
    --popover-border: #d0d0d0;
    --shadow: 0 8px 24px rgba(0,0,0,.18);
    --header-h: 40px;
    --header-bg1: #b3d9ff;
    --header-bg2: #b3d9ff;
    --sb-expanded: 210px;
    --sb-collapsed: 52px;
    /* Current sidebar width (updated by `initSidebar` on toggle) */
    --sb-current: var(--sb-collapsed);
}

/* -------------------------------------------------------------------------
   Full-width layout (100vw minus sidebar width)
   These pages render the sidebar + content inside a 2-column <table>.
   Make the table span the viewport and allocate the remaining width to the
   content cell based on the sidebar's current open/closed width.
   ------------------------------------------------------------------------- */

/*
   Inline sidebar is rendered in a 2-column table.
   Let the sidebar column size to its content (collapsed: icons only, expanded: icons+text)
   and let the content column take the remaining space.
*/
#master-grid > table,
#build-grid > table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
}

    #master-grid > table td:first-child,
    #build-grid > table td:first-child {
        /* keep sidebar as tight as possible */
        width: 1%;
        white-space: nowrap;
    }

    #master-grid > table td:last-child,
    #build-grid > table td:last-child {
        width: auto;
    }

/* Ensure the content containers fill their cell */
#master-grid-content,
#build-grid-content {
    width: 100%;
    box-sizing: border-box;
}

/* Ensure these containers are positioning contexts (no markup edit required) */
#master-grid, #classification-grid, #supplemental-grid {
    position: relative;
}

/* =========================
   ABSOLUTE MODE (overlay inside target container)
   ========================= */
.sb-abs {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--sb-expanded);
    height: 100%;
    background: #b3d9ff;
    border-right: 1px solid #e0e0e0;
    box-sizing: border-box;
    overflow: visible; /* popovers can overflow */
    z-index: 10;
    padding-top: var(--header-h);
}

/* =========================
   INLINE MODE (sits inside a <td>, no absolute, no container padding)
   ========================= */
.sb-inline {
    position: static; /* not absolute */
    display: inline-block; /* sits inline in the <td> */
    vertical-align: top;
    width: var(--sb-expanded); /* expanded width */
    background: #b3d9ff;
    border-right: 1px solid #e0e0e0;
    box-sizing: border-box;
    padding-top: var(--header-h);
}

    /* Compact width for INLINE mode */
    .sb-inline.compact {
        width: var(--sb-collapsed);
    }

/* Compact width for ABSOLUTE mode */
.sb-abs.compact {
    width: var(--sb-collapsed);
}

/* Shared header strip (works for both modes) */
.sb-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: linear-gradient(180deg, var(--header-bg1) 0%, var(--header-bg2) 100%);
}

/* For INLINE mode, keep header visible on scroll / within cell */
.sb-inline .sb-header {
    position: sticky;
    top: 0;
    height: 1px;
}

/* Chevron toggle (top-left) */
.sb-toggle {
    position: absolute;
    top: 4px;
    left: 0;
    width: 32px;
    height: 32px;
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
}

    .sb-toggle:focus-visible {
        outline: 2px solid #0078d4;
        outline-offset: 2px;
    }

/* (If you’re using <img class="sb-chevron left/right"> inside the button) */
.sb-chevron {
    display: none;
}
/* Show left chevron when NOT compact */
.sb-abs:not(.compact) .sb-chevron.left,
.sb-inline:not(.compact) .sb-chevron.left {
    display: block;
}
/* Show right chevron when compact */
.sb-abs.compact .sb-chevron.right,
.sb-inline.compact .sb-chevron.right {
    display: block;
}

/* =========================
   Table & rows (no flex)
   ========================= */

/* Scroll wrapper around the sidebar table so it can scroll vertically when content overflows */
.sb-table-wrap {
    width: 100%;
    height: calc(100vh - 110px);
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #b3d9ff;
}

.sb-inline .sb-table-wrap {
    max-height: none;
}

.sb-table {
    width: max-content;
    border-collapse: collapse;
    border-spacing: 0;
}

/* Expanded mode: make rows span the full sidebar width so hover fills the entire row */
.sb-abs:not(.compact) .sb-table,
.sb-inline:not(.compact) .sb-table {
    width: 100%;
}

.sb-table tr {
    height: var(--cell-h);
}

.sb-table td {
    vertical-align: middle;
}

.icon-cell {
    padding: 0;
    line-height: 0;
}

.label-cell {
    padding: 0 var(--pad-gap) 0 var(--pad-x);
    white-space: nowrap;
}

.sb-table tbody tr:hover {
    background: transparent;
}

/* Expanded mode: full-width row hover */
.sb-abs:not(.compact) .sb-table tbody tr:hover,
.sb-inline:not(.compact) .sb-table tbody tr:hover {
    background-color: #E0EFFF;
}

/* Group rows (Save/Execute): absolutely no hover effects on TR or TD */
/*.sb-table tbody tr.group-row:hover,
.sb-table tbody tr.group-row:hover > td {
    background: transparent !important;
    background-color: transparent !important;
    color: inherit !important;
    font: inherit !important;
    border: 0 !important;
    outline: none !important;
}*/

/* Simple row buttons */
.row-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: inherit;
    position: relative;
    overflow: visible;
}

/* Compact-mode tooltips for single-action sidebar items (avoid the browser `title` tooltip) */
.sb-abs.compact .row-action[data-tooltip]:not([data-tooltip=""])::after,
.sb-inline.compact .row-action[data-tooltip]:not([data-tooltip=""])::after,
.sb-abs.compact .sb-drop-zone-paste[data-tooltip]:not([data-tooltip=""])::after,
.sb-inline.compact .sb-drop-zone-paste[data-tooltip]:not([data-tooltip=""])::after,
.sb-abs.compact .virtual-grid-drop-zone-paste[data-tooltip]:not([data-tooltip=""])::after,
.sb-inline.compact .virtual-grid-drop-zone-paste[data-tooltip]:not([data-tooltip=""])::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 3px);
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    height: 30px;
    box-sizing: border-box;
    white-space: nowrap;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    padding: 6px 10px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 10pt;
    font-weight: normal;
    color: #000;
    opacity: 0;
    /* Tooltips should not steal hover/hit-testing from the grid when they render over it */
    pointer-events: none;
    cursor: default;
    z-index: 9999;
}

.sb-abs.compact .row-action[data-tooltip]:not([data-tooltip=""]):hover::after,
.sb-inline.compact .row-action[data-tooltip]:not([data-tooltip=""]):hover::after,
.sb-abs.compact .sb-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):hover::after,
.sb-inline.compact .sb-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):hover::after,
.sb-abs.compact .virtual-grid-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):hover::after,
.sb-inline.compact .virtual-grid-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):hover::after {
    opacity: 1;
}

/* Contenteditable upload zone can hold focus/caret; show tooltip on focus as well as hover */
.sb-abs.compact .sb-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):focus::after,
.sb-inline.compact .sb-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):focus::after,
.sb-abs.compact .sb-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):focus-within::after,
.sb-inline.compact .sb-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):focus-within::after,
.sb-abs.compact .virtual-grid-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):focus::after,
.sb-inline.compact .virtual-grid-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):focus::after,
.sb-abs.compact .virtual-grid-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):focus-within::after,
.sb-inline.compact .virtual-grid-drop-zone-paste[data-tooltip]:not([data-tooltip=""]):focus-within::after {
    opacity: 1;
}

/* Ensure the drop/paste zone can anchor its tooltip */
.sb-abs .sb-drop-zone-paste,
.sb-inline .sb-drop-zone-paste,
.sb-abs .virtual-grid-drop-zone-paste,
.sb-inline .virtual-grid-drop-zone-paste {
    position: relative;
}

/* Expanded sidebar: make single-action row labels match the Save/Delete/Execute option styling */
.sb-abs:not(.compact) .row-action span,
.sb-inline:not(.compact) .row-action span,
.sb-abs:not(.compact) .sb-drop-zone-paste span,
.sb-inline:not(.compact) .sb-drop-zone-paste span {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 10pt;
    font-weight: bold;
    font-style: normal;
    color: #333;
}

.row-action:focus-visible {
    outline: 2px solid #0078d4;
    border-radius: 6px;
    outline-offset: 2px;
}

.row-action img {
    width: var(--icon);
    height: var(--icon);
    display: block;
}

/* Sidebar-hosted VirtualGrid upload drop zone (reuse VirtualGrid classes, but override toolbar positioning) */
.sb-abs .sb-drop-zone,
.sb-inline .sb-drop-zone {
    position: static;
    left: auto;
    display: inline-block;
    padding-right: 0;
    gap: 0;
}

    .sb-abs .sb-drop-zone > *,
    .sb-inline .sb-drop-zone > * {
        border: 0;
        padding: 0;
        font-weight: inherit;
        border-radius: 0;
        transition: none;
    }

.sb-drop-zone-paste {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    outline: none;
}

    /* Ensure right-click targets the editable paste zone (not the image) so the browser enables Paste */
    .sb-drop-zone-paste img {
        pointer-events: none;
    }

    .sb-drop-zone-paste.is-dragover {
        outline: 2px dashed #0078d4;
        outline-offset: 2px;
        border-radius: 6px;
        background-color: rgba(0, 120, 212, 0.08);
    }

    .sb-drop-zone-paste:focus-visible {
        outline: 2px solid #0078d4;
        outline-offset: 2px;
        border-radius: 6px;
    }

/* Group rows (compact mode popovers) */
.group-row-hover {
    display: inline-block;
    position: relative;
}

.main-icon {
    width: var(--icon);
    height: var(--icon);
    display: inline-block;
    border-radius: 4px;
    outline: none;
}

    .main-icon:focus-visible {
        outline: 2px solid #0078d4;
        outline-offset: 2px;
    }

/* Popover (match undo/redo dropdown HEADER styling) */
.popover {
    position: absolute;
    top: 0;
    left: calc(100% + 4px); /* Align with undo/redo dropdowns (moved 4px closer) */
    min-width: 300px; /* Match undo/redo dropdown min-width */
    max-width: 400px; /* Match undo/redo dropdown max-width */
    background: #f8f9fa !important; /* Match undo/redo dropdown HEADER color */
    background-color: #f8f9fa !important;
    border: 1px solid #ddd; /* Match undo/redo dropdown border */
    border-radius: 4px; /* Match undo/redo dropdown border-radius */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); /* Match undo/redo dropdown shadow */
    padding: 0; /* Match undo/redo dropdown (no padding on container) */
    display: none;
    opacity: 0;
    transition: none !important; /* Disable all transitions */
    transform: none !important; /* Disable all transforms */
    z-index: 1001; /* Match undo/redo dropdown z-index */
}

    /* Popover hover - lock everything down */
    /*    .popover:hover {
        background: #f8f9fa !important;
        background-color: #f8f9fa !important;
        transform: none !important;
        filter: none !important;
    }*/

    .popover.open {
        display: block;
        opacity: 1;
    }

.options {
    display: grid;
    padding: 0 !important; /* Match undo/redo dropdown content (no padding) */
    margin: 0 !important;
    background: transparent !important;
}

/* Lock down options container on hover */
/*    .options:hover {
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        transform: none !important;
    }*/

.opt-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 12px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid #f0f0f0; /* Match undo/redo dropdown separator */
    padding: 8px 12px; /* Match undo/redo dropdown padding */
    cursor: pointer;
    border-radius: 4px; /* 4px border-radius for consistency */
    text-align: left;
    color: #333; /* Match undo/redo dropdown color */
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; /* Match body font */
    font-size: 10pt; /* Match undo/redo dropdown font size */
    font-weight: normal; /* Match undo/redo dropdown (not bold) */
    font-style: normal;
    width: 100%;
}

    .opt-item:hover,
    .opt-item:focus-visible {
        background-color: #E0EFFF;
    }

    /* Last item should not have bottom border */
    .opt-item:last-child {
        border-bottom: none;
    }

/* Popover options: absolutely no hover/active/focus visual effects - MOST AGGRESSIVE */
/*.popover .opt-item,
.popover .opt-item:hover,
.popover .opt-item:active,
.popover .opt-item:focus,
.popover .opt-item:focus-visible,
.popover button.opt-item,
.popover button.opt-item:hover,
.popover button.opt-item:active,
.popover button.opt-item:focus,
button.opt-item:hover,
button.opt-item:active,
button.opt-item:focus,
.options button.opt-item:hover,
.options button.opt-item:active,
.popover .options button.opt-item:hover,
.popover .options button.opt-item:active {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    color: #333 !important;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    font-size: 10pt !important;
    font-weight: normal !important;
    font-style: normal !important;
    text-decoration: none !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-top: 0 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    outline: none !important;
    box-shadow: none !important;
    filter: none !important;
    transform: none !important;
    transition: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}*/

/* Force last child to have no bottom border */
.popover .opt-item:last-child,
.popover button.opt-item:last-child,
.options button.opt-item:last-child {
    border-bottom: none !important;
}

.opt-item img {
    width: var(--icon);
    height: var(--icon);
    display: block;
}

.opt-item .opt-label {
    white-space: nowrap;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; /* Match body font */
    font-size: 10pt; /* Match undo/redo dropdown font size */
    font-weight: bold; /* Match undo/redo dropdown (bold operation names) */
    font-style: normal;
    color: #333; /* Match undo/redo dropdown color */
}

/* =========================
   COMPACT (icons-only) — apply to BOTH modes
   ========================= */

/* Hide inline row labels in compact */
.sb-abs.compact .row-action span,
.sb-inline.compact .row-action span {
    display: none;
}

/* Hide upload drop-zone label in compact */
.sb-abs.compact .sb-drop-zone-paste span,
.sb-inline.compact .sb-drop-zone-paste span {
    display: none;
}

/* Hide grouped label column in compact */
.sb-abs.compact .label-cell,
.sb-inline.compact .label-cell {
    display: none;
}

/* Tighten icons in compact */
.sb-abs.compact .row-action,
.sb-inline.compact .row-action {
    gap: 0;
}

/* Compact popover as icon tiles */
.sb-abs.compact .popover,
.sb-inline.compact .popover {
    min-width: auto;
    max-width: none;
    padding: 4px;
}

.sb-abs.compact .options,
.sb-inline.compact .options {
    display: grid;
    grid-auto-flow: row;
    grid-auto-rows: max-content;
    gap: 3px;
    align-items: center;
    justify-items: stretch;
}

.sb-abs.compact .opt-item,
.sb-inline.compact .opt-item {
    display: flex;
    align-items: center;
    justify-content: left;
    padding: 3px;
    width: 100%;
}

/* =========================
   EXPANDED (flat list; hide group rows) — BOTH modes
   ========================= */
.sb-abs:not(.compact) tr.group-row,
.sb-inline:not(.compact) tr.group-row {
    display: none;
}

.expanded-panel {
    display: none;
    margin-top: 12px;
    width: 100%;
}

.sb-abs:not(.compact) .expanded-panel,
.sb-inline:not(.compact) .expanded-panel {
    display: block;
}

.expanded-panel .section-title {
    font-weight: 600;
    font-size: 14px;
    color: #444;
    margin: 12px 0 2px;
}

.expanded-panel .section-rule {
    border: 0;
    border-top: 1px solid #e6e6e6;
    margin: 0 0 8px 0;
}

/* =========================
   Container padding toggle (used ONLY in absolute mode when script decides)
   ========================= */
.sb-pad-expanded {
    padding-left: var(--sb-expanded);
}

.sb-pad-collapsed {
    padding-left: var(--sb-collapsed);
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .popover {
        transition: none;
    }
}

/* Sidebar rows: don't change background while hovering inside a popover */
/*.sb-table tbody tr:has(.popover:hover) {
    background: transparent !important;
}*/

/* AFTER the aggressive rules: explicit hovered state for group-row popovers */
.opt-item:hover {
    background-color: #E0EFFF !important;
}

/* Sidebar single-action rows: match hover background to the dropdown items */
.row-action:hover,
.row-action:focus-visible {
    background-color: #E0EFFF;
    border-radius: 6px;
}

/* When expanded, the entire table row is highlighted; avoid a smaller nested highlight on the button itself */
.sb-abs:not(.compact) .row-action:hover,
.sb-inline:not(.compact) .row-action:hover {
    background-color: transparent;
}

/* Upload row behaves like a button */
.sb-drop-zone-paste:hover,
.sb-drop-zone-paste:focus-visible {
    background-color: #E0EFFF;
    border-radius: 6px;
}

/* Expanded mode uses full-row hover for the upload row as well */
.sb-abs:not(.compact) .sb-drop-zone-paste:hover,
.sb-inline:not(.compact) .sb-drop-zone-paste:hover {
    background-color: transparent;
}

/* Compact-mode group icons (Save/Delete/Execute right-arrow icons) */
.group-row-hover:hover .main-icon,
.group-row-hover:focus-within .main-icon {
    background-color: #E0EFFF;
}


/* Base look */
.sb-drop-zone {
    border: 2px dashed transparent; /* start invisible */
    border-radius: 6px;
    transition: border-color 120ms ease, background-color 120ms ease;
}

    /* When the mouse is dragging over (files) */
    .sb-drop-zone.is-dragover {
        border-color: #4caf50; /* green outline */
        background-color: rgba(76,175,80,0.08);
    }

    /* (Optional) also show on simple hover when not dragging */
    .sb-drop-zone:hover {
        border-color: #9e9e9e;
    }

/* =========================
   Sidebar Execute selects (Client / ALE Timing)
   ========================= */
.opt-select {
    background: transparent;
    border-bottom: 1px solid #f0f0f0;
}

    .opt-select table {
        width: 100%;
        border-collapse: collapse;
    }

    .opt-select tr {
        height: 30px;
    }

    .opt-select td {
        padding: 0; /* 🔥 most important fix */
        margin: 0;
        vertical-align: middle;
    }

.opt-select-label {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 10pt;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
}

.opt-select-input {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 11pt;
    font-weight: 600;
    color: #333;
    width: 100%;
    padding: 2px 6px; /* ✅ adds breathing room */
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #fff;
}

    /* Production-ish (PR2*) = warning yellow */
    .opt-select-input.client-env-prod {
        background-color: #fff8c4;
        border-color: #e0c200;
        color: #5c4400;
        font-weight: bold;
    }
    /* Test/QA/DV/SB = safe green */
    .opt-select-input.client-env-test {
        /*background-color: #e6f4ea;*/
        border-color: #4caf50;
        /*    color: #1b5e20;*/
        font-weight: bold;
    }
/* Option-level color cues (best-effort; not all browsers honor option styling) */
.opt-select-client option.client-env-prod {
    background-color: #fff8c4;
    color: #5c4400;
}

.opt-select-client option.client-env-test {
    /*background-color: #e6f4ea;*/
    /*    color: #1b5e20;*/
}

.mibt-floating-tooltip {
    position: fixed;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,.15);
    padding: 6px 10px;
    font: 10pt;
    color: #000;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2147483647;
}

/* ===== Grid-lock disabled state ===== */

/* Greyed-out text for labels, section titles, opt labels, and select labels */
.mibt-sidebar .is-disabled,
.mibt-sidebar .opt-label.is-disabled,
.mibt-sidebar .label-cell.is-disabled,
.mibt-sidebar .opt-select-label.is-disabled,
.mibt-sidebar .section-title.is-disabled,
.mibt-sidebar span.is-disabled {
    color: #9aa0a6 !important;
    opacity: 0.55;
    cursor: not-allowed;
}

/* Grey out images via filter so it doesn't depend on the asset itself */
.mibt-sidebar img.is-disabled {
    filter: grayscale(100%) opacity(0.5);
    cursor: not-allowed;
    pointer-events: none;
}

/* Disabled buttons: remove hover background, show not-allowed cursor */
.mibt-sidebar .row-action.is-disabled,
.mibt-sidebar .opt-item.is-disabled {
    cursor: not-allowed;
    background: transparent !important;
}

    .mibt-sidebar .row-action.is-disabled:hover,
    .mibt-sidebar .opt-item.is-disabled:hover {
        background: transparent !important;
    }

/* Disabled select inputs */
.mibt-sidebar .opt-select-input:disabled {
    color: #9aa0a6 !important;
    opacity: 0.55;
    cursor: not-allowed;
}
/* D365-specific color tokens (reusing MIBT palette) */
:root {
    --mibt-quick: #6f42c1;
    --mibt-quick-bg: #f3eefb;
}

/* Request list page */
.request-container {
    padding: 0px 20px 0px 20px;
    height: 100%;
    max-width: 100vw;
    width: calc(100vw - var(--sb-current, 0px));
    margin-left: calc(-1 * var(--sb-current, 0px));
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sap-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
    max-width: fit-content;
}

.sap-page-title {
    font-size: 16pt;
    font-weight: 600;
    color: var(--mibt-text, #32363a);
}

.sap-page-subtitle {
    font-size: 10pt;
    color: var(--mibt-text-muted, #6a6d70);
    margin-top: 4px;
}

/* Table container - wraps toolbar and table for shared width */
.table-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    width: fit-content;
    min-width: 600px;
    max-width: 100%;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background-color: #f4f5f6;
    border: 1px solid var(--mibt-border, #d5dadf);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    grid-column: 1;
}

.toolbar-left {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    gap: 8px;
}

.filter-chip {
    padding: 4px 12px;
    background-color: #eaecee;
    border-radius: 12px;
    font-size: 10pt;
    color: var(--mibt-text, #32363a);
}

.search-box {
    width: 240px;
    padding: 6px 10px;
    border: 1px solid #b3b8bd;
    border-radius: 4px;
    font-size: 11pt;
    font-family: inherit;
    background-color: #ffffff;
    color: var(--mibt-text, #32363a);
    height: 34px;
}

    .search-box:focus {
        outline: none;
        border-color: #0072ce;
        box-shadow: 0 0 0 2px rgba(0, 114, 206, 0.18);
    }

/* Data table wrapper - scrollable container for table */
.data-table-wrapper {
    width: 100%;
    grid-column: 1;
    height: calc(100vh - 185px);
    overflow: auto;
    position: relative;
    border: 1px solid var(--mibt-border, #d5dadf);
    border-radius: 0 0 4px 4px;
    background-color: #ffffff;
}

    /* Data table - styles for table elements inside wrapper */
    .data-table-wrapper table {
        min-width: 100%;
        border-collapse: collapse;
        table-layout: auto;
    }

    .data-table-wrapper thead {
        background: #f9f9f9;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .data-table-wrapper th {
        text-align: left;
        padding: 0 8px;
        margin: 0;
        border: 1px solid #ddd;
        font-weight: 700;
        color: var(--mibt-text, #32363a);
        white-space: nowrap;
        height: 35px;
        position: sticky;
        top: 0;
    }

    .data-table-wrapper td {
        padding: 9px 10px;
        font-size: 12pt;
        border-bottom: 1px solid var(--mibt-border-light, #eaecee);
        color: var(--mibt-text, #32363a);
    }

    .data-table-wrapper tbody tr.data-row {
        cursor: default;
    }

    .data-table-wrapper tbody {
        display: table-row-group;
    }

        .data-table-wrapper tbody::after {
            content: '';
            display: block;
            height: 20px;
        }

        /* Alternating row colors (zebra striping) */
        .data-table-wrapper tbody tr.data-row:nth-child(even) {
            background-color: #f9f9f9;
        }

        .data-table-wrapper tbody tr.data-row:hover {
            background-color: var(--mibt-row-hover, #E0EFFF);
        }

/* Quick edit state */
tr.quick-editing {
    background-color: var(--mibt-quick-bg) !important;
    box-shadow: inset 4px 0 0 var(--mibt-quick);
}

.quick-edit-input {
    padding: 4px 6px;
    font-size: 10pt;
    height: 28px;
    border: 1px solid var(--mibt-quick);
    border-radius: 3px;
    background-color: white;
    font-family: inherit;
    width: 100%;
    max-width: 160px;
}

    .quick-edit-input:focus {
        outline: none;
        box-shadow: 0 0 0 2px rgba(111, 66, 193, 0.2);
    }

/* Priority and Status badges */
.priority {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    font-size: 10pt;
}

.priority-high {
    color: var(--mibt-danger, #bb0000);
}

.priority-medium {
    color: var(--mibt-warn-fg, #b25400);
}

.priority-low {
    color: var(--mibt-text-muted, #6a6d70);
}

.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 9pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-open {
    background-color: var(--mibt-warn-bg, #fff4e5);
    color: var(--mibt-warn-fg, #b25400);
}

.status-progress {
    background-color: #e8f4ff;
    color: #0058c7;
}

.status-closed {
    background-color: #e6f4ea;
    color: var(--mibt-success, #107e3e);
}

.status-pending {
    background-color: var(--mibt-err-bg, #fde8e8);
    color: #a52a2a;
}

/* Row actions */
.actions-col {
    width: 110px;
    text-align: center;
}

.row-actions {
    display: inline-flex;
    gap: 2px;
    white-space: nowrap;
}

    .row-actions .btn-icon {
        padding: 3px 7px;
        font-size: 13px;
    }

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    color: #0072ce;
    font-size: 12pt;
    border-radius: 3px;
}

    .btn-icon:hover {
        background-color: var(--mibt-row-hover, #E0EFFF);
    }

.btn-icon-danger {
    color: var(--mibt-danger, #bb0000);
}

.btn-icon-quick {
    color: var(--mibt-quick);
}

.btn-icon-success {
    color: var(--mibt-success, #107e3e);
}

.btn-icon-insert {
    color: #0072ce;
}

.btn-icon-danger:hover {
    background-color: var(--mibt-err-bg, #fde8e8);
}

.btn-icon-quick:hover {
    background-color: var(--mibt-quick-bg);
}

.btn-icon-success:hover {
    background-color: #e6f4ea;
}

.btn-icon-insert:hover {
    background-color: #e0efff;
}

.actions-legend {
    font-size: 11px;
    color: var(--mibt-text-muted, #6a6d70);
    display: inline-flex;
    gap: 10px;
    align-items: center;
    padding: 4px 10px;
    background: #f4f5f6;
    border-radius: 11px;
}

    .actions-legend span {
        display: inline-flex;
        align-items: center;
        gap: 3px;
    }

/* Modal */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.45);
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
    z-index: 1000;
}

    .modal-backdrop.show {
        display: flex;
    }

@keyframes modalIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal {
    width: 92%;
    max-width: 1100px;
    height: calc(100vh - 40px);
    max-height: 95vh;
    border-radius: 6px;
    overflow: hidden;
    background-color: #ffffff;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    animation: modalIn 0.2s ease;
    position: relative;
    z-index: 1001;
    opacity: 1 !important;
    display: flex;
    flex-direction: column;
    resize: both;
    min-width: 600px;
    min-height: 400px;
}

.modal-header {
    background-color: #0072ce;
    color: white;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-backdrop[data-mode="edit"] .modal-header {
    background-color: var(--mibt-warn-fg, #b25400);
}

.modal-backdrop[data-mode="delete"] .modal-header {
    background-color: var(--mibt-danger, #bb0000);
}

.modal-title {
    font-size: 13pt;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

#direct-component-dialog-modal .virtual-grid-draggable-header {
    min-height: 43px;
    padding: 0 18px;
    cursor: move;
}

#direct-component-dialog-modal .editable-grid {
    width: max-content;
    min-width: 100%;
    max-width: none;
}

#direct-component-dialog-modal .editable-grid table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

#direct-component-dialog-modal .editable-grid th,
#direct-component-dialog-modal .editable-grid td {
    white-space: nowrap;
}

#direct-component-dialog-modal .editable-grid .form-input,
#direct-component-dialog-modal .editable-grid .form-select {
    min-width: 140px;
}

#direct-component-dialog-modal .d365-add-button {
    background: none !important;
    border: none !important;
    color: green !important;
    font-weight: 600;
    padding: 0;
    cursor: pointer;
}

#direct-component-dialog-modal .d365-add-button:hover {
    text-decoration: underline;
}

.modal-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
}

    .modal-close:hover {
        color: #ffb3b3;
    }

.modal-body {
    padding: 18px;
    overflow-y: auto;
    background-color: #FAFAFA;
    opacity: 1;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    padding: 12px 18px;
    background-color: #f4f5f6;
    border-top: 1px solid var(--mibt-border, #d5dadf);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: relative;
}

/* Resize handle indicator */
.modal::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient( 135deg, transparent 0%, transparent 40%, #999 40%, #999 45%, transparent 45%, transparent 55%, #999 55%, #999 60%, transparent 60%, transparent 70%, #999 70%, #999 75%, transparent 75% );
    pointer-events: none;
    opacity: 0.6;
}

.modal-footer-left {
    font-size: 11px;
    color: var(--mibt-text-muted, #6a6d70);
}

.modal-footer-right {
    display: flex;
    gap: 8px;
}

/* Mode banners */
.mode-banner {
    padding: 11px 14px;
    border-radius: 4px;
    font-size: 10pt;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid;
}

    .mode-banner.edit {
        background-color: var(--mibt-warn-bg, #fff4e5);
        border-color: #ffc999;
        color: var(--mibt-warn-fg, #b25400);
    }

    .mode-banner.delete {
        background-color: var(--mibt-err-bg, #fde8e8);
        border-color: #f5b3b3;
        color: var(--mibt-danger, #bb0000);
        font-weight: 600;
    }

/* Section cards (inside modal) */
.sap-section {
    background-color: #ffffff;
    border: 1px solid var(--mibt-border, #d5dadf);
    border-radius: 4px;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sap-section-header {
    background-color: #f4f5f6;
    border-bottom: 1px solid var(--mibt-border, #d5dadf);
    padding: 10px 14px;
    font-size: 10pt;
    font-weight: 700;
    color: #354a5f;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sap-section-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sap-section-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: none;
    font-weight: 400;
    color: var(--mibt-text-muted, #6a6d70);
    font-size: 10pt;
}

.sap-section-body {
    padding: 14px;
}

    .sap-section-body.no-pad {
        padding: 0;
    }

/* Form grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px 16px;
}

    .form-grid.cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-size: 10pt;
    font-weight: 600;
    color: var(--mibt-text, #32363a);
    display: flex;
    align-items: center;
    gap: 4px;
}

    .form-label .required {
        color: var(--mibt-danger, #bb0000);
    }

.form-input,
.form-select {
    padding: 6px 10px;
    border: 1px solid #b3b8bd;
    border-radius: 4px;
    font-size: 11pt;
    font-family: inherit;
    background-color: #ffffff;
    color: var(--mibt-text, #32363a);
    height: 34px;
}

    .form-input:focus,
    .form-select:focus {
        outline: none;
        border-color: #0072ce;
        box-shadow: 0 0 0 2px rgba(0, 114, 206, 0.18);
    }

/* Item group cards (multi-select) */
.item-group-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.item-group-card {
    position: relative;
    border: 2px solid var(--mibt-border, #d5dadf);
    border-radius: 6px;
    padding: 12px;
    cursor: pointer;
    text-align: center;
    background-color: #ffffff;
    transition: all 0.15s;
    user-select: none;
}

    .item-group-card:hover {
        border-color: #0072ce;
        background-color: #f4f9ff;
    }

    .item-group-card.selected {
        border-color: #0072ce;
        background-color: var(--mibt-row-selected, #D1E7FF);
        box-shadow: 0 2px 6px rgba(0, 114, 206, 0.18);
    }

        .item-group-card.selected::after {
            content: '✓';
            position: absolute;
            top: 4px;
            right: 6px;
            background-color: #0072ce;
            color: white;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 11px;
            font-weight: 700;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
        }

.item-group-card-icon {
    font-size: 22pt;
    margin-bottom: 6px;
}

.item-group-card-title {
    font-size: 11pt;
    font-weight: 700;
    color: var(--mibt-text, #32363a);
}

.item-group-card-code {
    font-size: 10px;
    color: var(--mibt-text-muted, #6a6d70);
    margin-top: 2px;
    font-weight: 600;
}

.type-selection-hint {
    margin-top: 10px;
    font-size: 11px;
    color: var(--mibt-text-muted, #6a6d70);
    text-align: center;
    font-style: italic;
}

    .type-selection-hint.error {
        color: var(--mibt-danger, #bb0000);
        font-weight: 700;
        font-style: normal;
    }

/* Compact mode for request types */
.item-group-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.item-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 2px solid var(--mibt-border, #d5dadf);
    border-radius: 20px;
    background-color: #ffffff;
    color: var(--mibt-text, #32363a);
    font-size: 11pt;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

    .item-chip:hover:not(:disabled) {
        border-color: #0072ce;
        background-color: #f4f9ff;
    }

    .item-chip.selected {
        border-color: #0072ce;
        background-color: var(--mibt-row-selected, #D1E7FF);
        color: #0072ce;
    }

    .item-chip:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* Editable grid (inside sub-forms) */
.editable-grid table {
    font-size: 10pt;
}

.editable-grid th {
    padding: 7px 8px;
    background-color: #eaecee;
}

.editable-grid td {
    padding: 3px 5px;
}

.editable-grid .form-input,
.editable-grid .form-select {
    padding: 5px 6px;
    font-size: 10pt;
    height: 30px;
    width: 100%;
    border: 1px solid transparent;
    background-color: transparent;
}

.editable-grid tr:hover .form-input,
.editable-grid tr:hover .form-select {
    border-color: #d5dadf;
    background-color: #ffffff;
}

.editable-grid .form-input:focus,
.editable-grid .form-select:focus {
    border-color: #0072ce;
    background-color: #ffffff;
}

/* Formula card (nested formulas) */
.formula-card {
    background-color: #ffffff;
    border: 1px solid var(--mibt-border, #d5dadf);
    border-left: 4px solid #354a5f;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 10px;
}

.formula-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mibt-border-light, #eaecee);
}

.formula-card-title {
    font-weight: 700;
    font-size: 11pt;
    color: #354a5f;
}

/* Alternating row colors for formula lines tables */
.formula-card table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.grid-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px;
    background-color: #f4f5f6;
    border-bottom: 1px solid var(--mibt-border, #d5dadf);
}

.grid-toolbar-title {
    font-size: 11px;
    font-weight: 700;
    color: #354a5f;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.btn-danger-ghost {
    color: var(--mibt-danger, #bb0000);
    border-color: #f5b3b3;
    background-color: #ffffff;
}

    .btn-danger-ghost:hover {
        background-color: var(--mibt-err-bg, #fde8e8);
    }

.text-link {
    color: #0072ce;
    text-decoration: none;
    font-weight: 600;
}

    .text-link:hover {
        text-decoration: underline;
    }

/* D365 Sub-navigation */
.d365-subnav {
    display: flex;
    justify-content: center;
    gap: 4px;
    background-color: #b3d9ff !important;
    border-bottom: 2px solid var(--mibt-border, #d5dadf);
    padding: 0;
    margin: 0;
    position: relative;
    left: calc(-1 * var(--sb-current, 0px));
    width: 100vw !important;
    height: 40px;
    align-items: center;
}

.d365-subnav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 5px;
    text-decoration: none;
    color: #333333 !important;
    font-size: 13pt !important;
    font-weight: bold !important;
    transition: all 0.15s;
    background-color: transparent;
    white-space: nowrap;
    cursor: pointer;
}

    .d365-subnav-item:hover {
        background-color: white !important;
    }

    .d365-subnav-item.active {
        position: relative;
        background-color: white !important;
        color: #0072ce !important;
    }

        .d365-subnav-item.active::after {
            content: "";
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            height: 5px;
            background: white;
        }

.d365-subnav-icon {
    font-size: 14pt;
}

/* Child row expansion */
.expand-col {
    width: 30px;
    text-align: center;
    padding: 0 !important;
}

.chevron-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 10px;
    color: #0072ce;
    transition: transform 0.2s;
}

    .chevron-btn:hover {
        color: #005a9e;
    }

.expansion-row {
    display: none;
    background-color: #f8f9fa;
}

    .expansion-row.show {
        display: table-row;
    }

.expansion-content {
    padding: 16px;
}

.expansion-section {
    margin-bottom: 16px;
}

    .expansion-section:last-child {
        margin-bottom: 0;
    }

.expansion-title {
    font-weight: 700;
    font-size: 12px;
    color: #354a5f;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.count-pill {
    display: inline-block;
    background-color: #0072ce;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
}

.child-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12pt;
    background-color: white;
    border: 1px solid var(--mibt-border, #d5dadf);
}

    .child-table thead {
        background: #f9f9f9;
    }

    .child-table th {
        text-align: left;
        padding: 0 8px;
        margin: 0;
        border: 1px solid #ddd;
        font-weight: 700;
        color: var(--mibt-text, #32363a);
        white-space: nowrap;
        height: 35px;
    }

    .child-table td {
        padding: 0 8px;
        height: 35px;
        font-size: 12pt;
        border: 1px solid #ddd;
        color: var(--mibt-text, #32363a);
        white-space: nowrap;
        vertical-align: middle;
    }

    /* Alternating row colors for child tables */
    .child-table tbody tr:nth-child(even) {
        background-color: #f9f9f9;
    }

    .child-table tbody tr:hover {
        background-color: #f8f9fa;
    }

/* Formula lines nested expansion */
.formula-lines-expansion {
    background-color: #f8f9fa !important;
}

    .formula-lines-expansion:hover {
        background-color: #f8f9fa !important;
    }

    .formula-lines-expansion table tbody tr:nth-child(even) {
        background-color: #f9f9f9;
    }

    .formula-lines-expansion table tbody tr:hover {
        background-color: #e8ecef;
    }

.empty-expansion {
    padding: 12px;
    text-align: center;
    color: var(--mibt-text-muted, #6c757d);
    font-size: 11px;
    font-style: italic;
    background-color: white;
    border: 1px dashed var(--mibt-border, #d5dadf);
    border-radius: 4px;
}

.type-chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.type-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    color: #354a5f;
}

.type-chip-icon {
    font-size: 18px;
    cursor: default;
}

.type-chip-sep {
    color: var(--mibt-text-muted, #6c757d);
}

.data-row.expanded {
    background-color: #f0f7ff;
}

/* Formula card layout */
.formula-card {
    border: 1px solid var(--mibt-border, #d5dadf);
    border-radius: 4px;
    background-color: white;
    overflow: hidden;
}

.formula-card-header {
    padding: 10px 14px;
    background-color: #f4f5f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--mibt-border, #d5dadf);
}

.formula-card-title {
    font-size: 11pt;
    font-weight: 600;
    color: var(--mibt-text, #32363a);
}

.formula-card-actions {
    display: inline-flex;
    gap: 4px;
}

/* D365 page scrollable container — flex-fill replaces fixed calc() height */
#d365-grid .data-table-wrapper {
    width: fit-content;
    min-width: 600px;
    max-width: 100%;
    flex: 1;
    min-height: 0;
    height: auto; /* cancel global height: calc(100vh - 185px) so flex controls this */
    overflow: auto;
    background-color: #ffffff;
    border: 1px solid var(--mibt-border, #d5dadf);
    border-radius: 0 0 4px 4px;
    padding: 0px !important;
    box-sizing: border-box;
    position: relative;
}

/* Ensure D365 tables have minimum width to prevent jagged edges */
.data-table-wrapper table {
    min-width: 620px;
}

/* =============================================================================
   D365 row look-and-feel — match the normal RequestAdmin virtual-grid-table-row
   style: compact 35 px height, full cell borders, nowrap, and consistent
   hover / zebra / selected / disabled states.
   ============================================================================= */

#d365-grid .data-table-wrapper td {
    padding: 0 8px;
    height: 35px;
    font-size: 12pt;
    border: 1px solid #ddd;
    color: var(--mibt-text, #32363a);
    white-space: nowrap;
    vertical-align: middle;
}

/* Zebra striping — even data rows */
#d365-grid .data-table-wrapper tbody tr.data-row:nth-child(even) {
    background-color: #f9f9f9;
}

/* Row hover — same blue tint as the virtual grid */
#d365-grid .data-table-wrapper tbody tr.data-row:hover {
    background-color: var(--mibt-row-hover, #E0EFFF);
}

/* Selected row — soft green, same as request.css .selected-row */
#d365-grid .data-table-wrapper tbody tr.data-row.selected-row,
#d365-grid .data-table-wrapper tbody tr.data-row.selected-row td {
    background-color: #e2f5e2 !important;
}

/* Disabled / locked row — greyed out, matching .disabled-row */
#d365-grid .data-table-wrapper tbody tr.data-row.disabled-row {
    opacity: 0.6;
}

/* Expansion rows — keep the softer background, no zebra interference */
#d365-grid .data-table-wrapper tbody tr.expansion-row > td {
    padding: 0;
    border: none;
    height: auto;
    white-space: normal;
}

/* #endregion */

/* D365-only layout fix: keep grids fit-to-table, centered, and scrollable */
#d365-grid .visible {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

#d365-grid .request-container {
    height: calc(100% - 5px);
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

#d365-grid .table-container {
    width: fit-content;
    min-width: 0;
    max-width: 100%;
    flex: 0 1 auto;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0 auto;
}

#d365-grid .data-table-wrapper {
    width: fit-content;
    min-width: 600px;
    max-width: 100%;
    flex: 0 1 auto;
    min-height: 0;
    max-height: 100%;
    height: auto;
    overflow: auto;
    position: relative;
    border-radius: 6px;
}

#d365-grid .data-table-wrapper table {
    border-radius: 6px;
    overflow: hidden;
}

#d365-grid .data-table-wrapper thead th:first-child {
    border-top-left-radius: 6px;
}

#d365-grid .data-table-wrapper thead th:last-child {
    border-top-right-radius: 6px;
}

#d365-admin-grid-footer,
#d365-request-grid-footer {
    flex: 0 0 auto;
    align-self: center;
    max-width: 100%;
}

/* ===========================================================================
   D365 inline validation
   - .input-error: red border on the offending input
   - .field-error: small red message rendered directly underneath the input
   - .d365-validation-banner: compact summary above the modal body
   =========================================================================== */
.form-input.input-error,
.form-select.input-error,
textarea.form-input.input-error {
    border-color: var(--mibt-danger, #c0392b) !important;
    box-shadow: 0 0 0 1px var(--mibt-danger, #c0392b) inset;
    background-color: #fff5f5;
}

.field-error {
    color: var(--mibt-danger, #c0392b);
    font-size: 0.75rem;
    line-height: 1.2;
    margin-top: 3px;
    display: block;
}

.editable-grid td .field-error {
    margin-top: 2px;
    white-space: normal;
    max-width: 220px;
}

.d365-validation-banner {
    margin: 0 0 12px;
    padding: 8px 12px;
    border: 1px solid var(--mibt-danger, #c0392b);
    background-color: #fff5f5;
    color: var(--mibt-danger, #c0392b);
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.d365-validation-banner .d365-validation-banner-icon {
    font-size: 1rem;
    line-height: 1;
}

