/* ============================================
   Microsoft Dynamics 365 Unified Service Desk Theme
   TMS Web Application
   ============================================ */

/* === CSS Variables - D365 USD Color Palette === */
:root {
    /* Primary Colors - D365 Blue */
    --d365-primary: #2266e3;
    --d365-primary-dark: #1b52b3;
    --d365-primary-light: #4d8df7;
    --d365-primary-lighter: #e8f0fe;
    
    /* Header - deep navy → royal blue (profile-badge style) */
    --d365-header-bg: #000A3A;
    --d365-header-bg-gradient: linear-gradient(90deg, #002B7F 0%, #001a55 48%, #000A3A 100%);
    --d365-header-secondary: #001435;
    --d365-header-height: 56px;
    
    /* Sidebar Navigation */
    --d365-sidebar-bg: #f8f9fa;
    --d365-sidebar-hover: #e9ecef;
    --d365-sidebar-active: #e3f2fd;
    --d365-sidebar-border: #dee2e6;
    --d365-sidebar-width: 256px;
    --d365-sidebar-collapsed-width: 64px;
    --d365-sidebar-transition: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Accent Colors */
    --d365-success: #107c10;
    --d365-warning: #ff8c00;
    --d365-danger: #d13438;
    --d365-info: #0078d4;
    --d365-orange: #ca5010;
    
    /* Background Colors */
    --d365-bg-primary: #ffffff;
    --d365-bg-secondary: #f3f2f1;
    --d365-bg-tertiary: #edebe9;
    --d365-bg-page: #faf9f8;
    
    /* Border Colors */
    --d365-border: #e1dfdd;
    --d365-border-dark: #c8c6c4;
    --d365-border-light: #f3f2f1;
    
    /* Text Colors */
    --d365-text-primary: #323130;
    --d365-text-secondary: #605e5c;
    --d365-text-muted: #a19f9d;
    --d365-text-inverse: #ffffff;
    --d365-link: #2266e3;
    
    /* Command Bar */
    --d365-commandbar-bg: #f3f2f1;
    --d365-commandbar-border: #e1dfdd;
    
    /* Shadow */
    --d365-shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
    --d365-shadow-md: 0 2px 4px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    --d365-shadow-lg: 0 4px 8px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.08);
    
    /* Typography - Segoe UI like D365 */
    --d365-font-family: 'Segoe UI', 'Segoe UI Web', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    --d365-font-size-xs: 11px;
    --d365-font-size-sm: 12px;
    --d365-font-size-md: 13px;
    --d365-font-size-lg: 14px;
    --d365-font-size-xl: 17px;
    --d365-font-size-xxl: 20px;
    --d365-form-heading-font: var(--d365-font-family), 'Beyonder', 'Beyonders', sans-serif;
    --d365-form-heading-color: #374151;
    --d365-form-heading-size: var(--ui-heading-font-size, 18px);
    --d365-dashboard-heading-size: 14px;
    
    /* Spacing */
    --d365-spacing-xs: 4px;
    --d365-spacing-sm: 8px;
    --d365-spacing-md: 12px;
    --d365-spacing-lg: 16px;
    --d365-spacing-xl: 24px;
    
    /* Border Radius */
    --d365-radius-sm: 2px;
    --d365-radius-md: 4px;
    --d365-radius-lg: 6px;
    
    /* Transitions */
    --d365-transition: all 0.15s ease;
}

/* === Base Styles === */
html, body {
    font-family: var(--d365-font-family);
    font-size: var(--d365-font-size-md);
    color: var(--d365-text-primary);
    background-color: var(--d365-bg-page);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.4;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--d365-text-primary);
    margin-bottom: var(--d365-spacing-md);
    line-height: 1.3;
}

h1 { font-size: var(--d365-font-size-xxl); }
h1.d365-page-heading-title {
    font-size: var(--d365-form-heading-size);
    font-weight: 700;
    margin-bottom: 0;
}
h2 { font-size: var(--d365-font-size-xl); }
h3 { font-size: var(--d365-font-size-lg); font-weight: 600; }
h4 { font-size: var(--d365-font-size-md); font-weight: 600; }

a { color: var(--d365-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === D365 Header Bar (Top Navigation) — covers hamburger === */
.d365-header {
    background: var(--d365-header-bg-gradient, var(--d365-header-bg));
    height: var(--d365-header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--d365-spacing-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    gap: var(--d365-spacing-sm);
}

.d365-header-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 1.25rem;
    flex-shrink: 0;
}

.d365-header-meta {
    display: flex;
    align-items: flex-end;
    gap: 1.25rem;
}

.d365-header-datetime {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.d365-header-meta-top {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.d365-header-date,
.d365-header-time {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
}

.d365-header-date {
    color: rgba(255, 255, 255, 0.82);
    font-size: 11px;
    font-weight: 600;
}

.d365-header-date i {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
}

.d365-header-time {
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.d365-header-time i {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.55);
}

.d365-header-timezone {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.d365-header-timezone i {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    flex-shrink: 0;
}

.d365-header-timezone-select {
    background: transparent;
    color: rgba(255, 255, 255, 0.82);
    border: none;
    border-radius: 0;
    font-size: 11px;
    font-weight: 600;
    padding: 0 1rem 0 0;
    cursor: pointer;
    max-width: 9.5rem;
}

.d365-header-timezone-select:hover {
    color: rgba(255, 255, 255, 0.95);
}

.d365-header-timezone-select:focus {
    outline: none;
    color: #ffffff;
}

.d365-header-timezone-select option {
    background: var(--d365-header-bg);
    color: #ffffff;
}

.d365-header-divider {
    width: 1px;
    height: 2rem;
    background: rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
}

.d365-header-search-btn {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.05rem;
    padding: 0.35rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--d365-transition);
}

.d365-header-home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.05rem;
    padding: 0.35rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--d365-transition);
    text-decoration: none;
}

.d365-header-home-btn:hover,
.d365-header-home-btn:focus-visible,
.d365-header-home-btn.active {
    color: #ffffff;
    outline: none;
    text-decoration: none;
}

.d365-header-search-btn:hover,
.d365-header-search-btn:focus-visible {
    color: #ffffff;
    outline: none;
}

.d365-header-brand {
    display: flex;
    align-items: center;
    gap: var(--d365-spacing-sm);
    color: var(--d365-text-inverse);
    font-size: var(--d365-font-size-lg);
    font-weight: 600;
}

.d365-header-brand i {
    font-size: 18px;
    color: #4d8df7;
}

.d365-header-recent {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
    position: relative;
}

.d365-header-recent-item {
    width: 42px;
    height: 42px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    color: rgba(255,255,255,0.82);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    text-decoration: none;
    transition: var(--d365-transition);
}

.d365-header-recent-item i {
    font-size: 16px;
    color: inherit;
}

.d365-header-recent-short {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 10px;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.25px;
    text-transform: uppercase;
    color: inherit;
}

.d365-header-recent-item:hover,
.d365-header-recent-item.active {
    color: #ffffff;
    background: transparent;
    border-bottom: 3px solid var(--d365-primary);
    text-decoration: none;
}

.d365-header-recent-more {
    position: relative;
}

.d365-header-recent-chevron {
    width: 28px;
    height: 42px;
    border-radius: 4px;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--d365-transition);
}

.d365-header-recent-chevron:hover,
.d365-header-recent-chevron.open {
    background: transparent;
    color: #ffffff;
    border-bottom: 2px solid transparent; /* removed underline hover from chevron */
}

.d365-header-recent-chevron i {
    font-size: 14px;
    color: #ffffff;
}

.d365-header-recent-chevron.open i {
    transform: rotate(180deg);
}

.d365-header-recent-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 190px;
    background: #ffffff;
    border: 1px solid var(--d365-border);
    border-radius: 6px;
    box-shadow: var(--d365-shadow-lg);
    padding: 4px;
    z-index: 1200;
}

.d365-header-recent-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    color: var(--d365-text-primary);
    text-decoration: none;
    font-size: 11px;
}

.d365-header-recent-dropdown-item:hover,
.d365-header-recent-dropdown-item.active {
    background: var(--d365-bg-secondary);
    text-decoration: none;
    color: var(--d365-text-primary);
}

.d365-header-recent-dropdown-item i {
    font-size: 12px;
    color: var(--d365-primary);
}

.d365-header-recent-dropdown-short {
    min-width: 44px;
    font-weight: 700;
    font-size: 10px;
    color: var(--d365-primary);
}

.d365-header-recent-dropdown-title {
    color: var(--d365-text-secondary);
    white-space: nowrap;
}

.d365-header-nav {
    display: flex;
    align-items: center;
    gap: 0;
}

.d365-header-nav-item {
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    padding: 6px 12px;
    transition: var(--d365-transition);
    text-decoration: none;
    font-size: var(--d365-font-size-sm);
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
}

.d365-header-nav-item:hover {
    color: #ffffff;
    background-color: rgba(255,255,255,0.1);
    text-decoration: none;
}

.d365-header-recent-desktop-only {
    display: inline-flex;
}

.d365-header-user {
    display: block;
    position: relative;
    flex-shrink: 0;
}

.d365-header-user-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #60a5fa;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--d365-transition);
    box-shadow: 0 4px 14px rgba(96, 165, 250, 0.25);
}

.d365-header-user-btn:hover,
.d365-header-user-btn:focus-visible {
    background: #3b82f6;
    outline: none;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
}

.d365-header-user-avatar {
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1;
}

.d365-header-user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: #ffffff;
    border: 1px solid var(--d365-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 8px;
    z-index: 1100;
}

.d365-header-user-name {
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--d365-text-primary);
    border-bottom: 1px solid var(--d365-border-light);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.d365-header-user-signout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--d365-text-primary);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
}

.d365-header-user-signout:hover {
    background: var(--d365-bg-secondary);
    color: var(--d365-danger);
}

/* === D365 Sidebar Navigation (HRMS-inspired) === */
.d365-sidebar {
    width: var(--d365-sidebar-width);
    background-color: #ffffff;
    height: 100%;
    border-right: 1px solid #d1d5db;
    display: flex;
    flex-direction: column;
    transition:
        width var(--d365-sidebar-transition),
        box-shadow var(--d365-sidebar-transition),
        background-color var(--d365-sidebar-transition);
    position: relative;
    flex-shrink: 0;
    overflow: visible;
    will-change: width;
    z-index: 1100;
}

.d365-sidebar-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: visible;
}

/* Full-height nav panel divider — visible through home/top area above CRUD overlap */
.d365-sidebar-shell::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 1px;
    background: #d1d5db;
    pointer-events: none;
    z-index: 1204;
}

.d365-sidebar.collapsed {
    width: var(--d365-sidebar-collapsed-width);
}

.d365-sidebar-nav {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: var(--d365-sidebar-collapsed-width);
    transition: opacity 200ms ease;
    overflow: hidden;
}

/* --- D365-style top rail (search + lock) --- */
.d365-nav-top-rail {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
    background: #ffffff;
    position: relative;
    z-index: 1;
}

.d365-nav-search {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.d365-nav-search:focus-within {
    border-color: #93c5fd;
    background: #ffffff;
}

.d365-nav-search-icon {
    color: #9ca3af;
    font-size: 14px;
    flex-shrink: 0;
}

.d365-nav-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: #374151;
    font-size: 13px;
    line-height: 1.4;
    outline: none;
}

.d365-nav-search-input::placeholder {
    color: #9ca3af;
}

.d365-nav-top-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 36px;
    border: none;
    background: transparent;
    color: #374151;
    text-decoration: none;
    cursor: pointer;
    position: relative;
    padding: 0;
    border-radius: 8px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.d365-nav-top-btn:hover {
    background: #f3f4f6;
    color: #111827;
}

.d365-nav-top-btn i {
    font-size: 16px;
    line-height: 1;
}

.d365-nav-top-home {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 36px;
    color: #374151;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.d365-nav-top-home:hover {
    background: #f3f4f6;
    color: #111827;
    text-decoration: none;
}

.d365-nav-top-home i {
    font-size: 18px;
    line-height: 1;
}

.d365-nav-top-home.active {
    color: #0d6efd;
}

/* Lock badge — sits on nav edge, fully visible above content */
.d365-nav-lock-btn {
    position: absolute;
    right: 0;
    top: 52px;
    transform: translateX(50%);
    width: 22px;
    height: 22px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1205;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
    transition: box-shadow 200ms ease, color 200ms ease, background-color 200ms ease, border-color 200ms ease;
    padding: 0;
    color: #6b7280;
    line-height: 0;
    pointer-events: auto;
}

.d365-nav-lock-btn i {
    font-size: 11px;
    line-height: 1;
    display: block;
}

.d365-nav-lock-btn:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
    color: #374151;
}

.d365-nav-lock-btn.is-locked {
    color: #2563eb;
    border-color: #93c5fd;
    background: #eff6ff;
}

.d365-nav-search-hidden {
    display: none !important;
}

.d365-sidebar-nav.is-searching .d365-nav-group:not(:has(.d365-nav-group-items .d365-nav-item)) {
    display: none !important;
}

.d365-sidebar-nav.is-searching .d365-nav-search-trigger {
    display: none !important;
}

.d365-nav-search-trigger {
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

/* Legacy floating lock duplicate (removed) */
.d365-nav-lock-btn.d365-nav-lock-btn-legacy {
    display: none;
}

/* Legacy brand header (unused — kept for reference in collapsed overrides below) */
.d365-nav-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px;
    background: #ffffff;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
    min-height: 58px;
}

.d365-nav-brand-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.d365-nav-brand-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.d365-nav-brand-logo i {
    font-size: 16px;
    color: #ffffff;
}

.d365-nav-brand-text {
    font-weight: 600;
    font-size: 16px;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    max-width: 180px;
    transition: opacity 220ms ease, max-width var(--d365-sidebar-transition);
}

.d365-sidebar.collapsed .d365-nav-top-rail {
    align-items: center;
    justify-content: center;
    padding: 10px 0 8px;
}

.d365-sidebar.collapsed .d365-nav-top-home {
    width: 40px;
    min-height: 40px;
}

.d365-sidebar.collapsed .d365-nav-lock-btn {
    top: 48px;
}

/* --- Collapse toggle button (legacy — replaced by lock) --- */
.d365-nav-collapse-btn {
    position: absolute;
    right: -12px;
    top: 80px;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 200ms ease, color 200ms ease;
    padding: 0;
    color: #6b7280;
    font-size: 12px;
}

.d365-nav-collapse-btn:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    color: #374151;
}

.d365-nav-collapse-btn.is-pinned {
    color: #6d28d9;
    border-color: #c4b5fd;
    background: #faf5ff;
}

@media (min-width: 769px) {
    .d365-app-container {
        position: relative;
        width: 100%;
    }

    .d365-page.sidebar-overlay-content .d365-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100%;
        z-index: 1100;
        flex-shrink: 0;
    }

    .d365-page.sidebar-overlay-content .d365-sidebar.collapsed {
        box-shadow: none;
    }

    .d365-page.sidebar-overlay-content .d365-sidebar:not(.collapsed),
    .d365-page.sidebar-overlay-content .d365-sidebar.pinned {
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.14);
    }

    /* CRUD stays fixed like the form — expanded nav overlays it (no resize) */
    .d365-page.sidebar-overlay-content .d365-main-content > .d365-command-bar {
        margin-left: calc(-1 * var(--d365-spacing-lg) + 1px);
        width: calc(100% + (2 * var(--d365-spacing-lg)) - 1px);
        box-sizing: border-box;
    }

    .d365-page.sidebar-overlay-content .d365-main-content {
        width: 100%;
        max-width: 100%;
        flex: 1 1 auto;
        min-width: 0;
        margin-left: 0;
        padding-left: calc(var(--d365-spacing-lg) + var(--d365-sidebar-collapsed-width));
        box-sizing: border-box;
        transition: padding-left var(--d365-sidebar-transition);
    }

    /* Advanced search only — lift content above overlay sidebar while dialog is open */
    .d365-page.sidebar-overlay-content:has(.adv-search-modal.show) .d365-main-content {
        position: relative;
        z-index: 1200;
    }

    .d365-sidebar.collapsed:not(.pinned) {
        z-index: 1100;
    }
}

/* --- Scrollable nav content --- */
.d365-nav-content {
    display: flex;
    align-items: stretch;
    gap: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 12px;
    position: relative;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.d365-nav-collapsed-rail {
    display: none;
}

.d365-nav-menu-items {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

/* Hide sidebar scrollbar while keeping scroll */
.d365-nav-content::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* --- Section headers (uppercase gray like HRMS) --- */
.d365-nav-subheader {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    color: #9ca3af;
    letter-spacing: 0.5px;
    padding: 16px 12px 6px 12px;
}

/* --- Nav items (rounded like HRMS) --- */
.d365-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    height: 38px;
    color: #6b7280;
    text-decoration: none;
    font-size: 13px;
    transition: all 200ms ease;
    cursor: pointer;
    border-radius: 8px;
    border: none;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.d365-nav-item:hover {
    background-color: #f9fafb;
    color: #111827;
    text-decoration: none;
}

.d365-nav-item.active {
    background-color: #faf5ff;
    color: #6d28d9;
    font-weight: 500;
    border-right: 2px solid #a855f7;
}

.d365-nav-dashboard-wrap {
    padding: 12px 12px 0 12px;
    background: #ffffff;
    flex-shrink: 0;
}

/* Active dot indicator (like HRMS) */
.d365-nav-item.active::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    background: #a855f7;
    border-radius: 50%;
}

.d365-nav-icon {
    width: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.d365-nav-icon i {
    font-size: 14px;
    color: #9ca3af;
}

.d365-nav-item:hover .d365-nav-icon i {
    color: #6b7280;
}

.d365-nav-item.active .d365-nav-icon i {
    color: #9333ea;
}

.d365-nav-text {
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    white-space: nowrap;
    opacity: 1;
    max-width: 180px;
    transition: opacity 220ms ease, max-width var(--d365-sidebar-transition);
}

.d365-sidebar.collapsed .d365-nav-text {
    opacity: 0;
    max-width: 0;
}

.d365-nav-section-header {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    color: #9ca3af;
    letter-spacing: 0.5px;
    padding: 16px 12px 6px 12px;
    display: block;
    flex-shrink: 0;
    line-height: 1.4;
    white-space: nowrap;
}

.d365-nav-chevron {
    font-size: 10px;
    color: #d1d5db;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 1;
    max-width: 16px;
    transition: opacity 200ms ease, max-width var(--d365-sidebar-transition);
}

.d365-sidebar.collapsed .d365-nav-chevron {
    opacity: 0;
    max-width: 0;
}

/* --- Group headers --- */
.d365-nav-group {
    margin-bottom: 8px;
}

.d365-nav-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0 12px;
    height: 38px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    margin-bottom: 4px;
    background: none;
    border: none;
    text-align: left;
}

.d365-nav-group-header:hover {
    background-color: #f9fafb;
}

.d365-nav-group-header .d365-nav-icon i {
    color: #9ca3af;
}

.d365-nav-group-items .d365-nav-item {
    padding-left: 36px;
    font-size: 12px;
}

.d365-nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.d365-nav-divider {
    height: 1px;
    background-color: #f3f4f6;
    margin: 8px 12px;
}

/* --- Sidebar footer --- */
.d365-nav-footer {
    border-top: 1px solid #f3f4f6;
    padding: 12px;
    flex-shrink: 0;
}

.d365-nav-footer-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.d365-nav-footer-actions {
    margin-top: 10px;
}

.d365-nav-footer-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.d365-nav-footer-logout:hover {
    background: #f9fafb;
    color: #111827;
}

.d365-nav-footer-logout .d365-nav-icon i {
    color: #9ca3af;
}

.d365-nav-footer-avatar {
    width: 32px;
    height: 32px;
    background: #60a5fa;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(96, 165, 250, 0.25);
    overflow: hidden;
}

.d365-nav-footer-avatar .d365-header-user-avatar {
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1;
    white-space: nowrap;
}

.d365-nav-footer-name {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    max-width: 160px;
    transition: opacity 220ms ease, max-width var(--d365-sidebar-transition);
}

.d365-sidebar.collapsed .d365-nav-footer-name {
    opacity: 0;
    max-width: 0;
}

/* --- Collapsed state --- */
.d365-sidebar.collapsed .d365-nav-brand {
    justify-content: center;
    padding: 10px 0;
    min-height: 52px;
}

.d365-sidebar.collapsed .d365-nav-brand-left {
    justify-content: center;
}

.d365-sidebar.collapsed .d365-nav-brand-logo {
    width: 28px;
    height: 28px;
}

.d365-sidebar.collapsed .d365-nav-brand-logo i {
    font-size: 14px;
}

.d365-sidebar.collapsed .d365-nav-content {
    padding: 10px 0;
    justify-content: center;
}

.d365-sidebar.collapsed .d365-nav-collapsed-rail {
    display: none;
}

.d365-sidebar.collapsed .d365-nav-menu-items {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0;
    width: 100%;
}

.d365-sidebar.collapsed .d365-nav-item {
    width: 40px;
    height: 40px;
    justify-content: center;
    padding: 0;
    border-radius: 8px;
    margin: 0 auto;
    border-right: none;
    position: relative;
}

.d365-sidebar.collapsed .d365-nav-item.active::after {
    display: none;
}

.d365-sidebar.collapsed .d365-nav-item.active,
.d365-sidebar.collapsed .d365-nav-group-header.active {
    background-color: #ffffff;
    color: #0d6efd;
    box-shadow: none;
}

.d365-sidebar.collapsed .d365-nav-item.active .d365-nav-icon i,
.d365-sidebar.collapsed .d365-nav-group-header.active .d365-nav-icon i {
    color: #0d6efd;
}

.d365-sidebar.collapsed .d365-nav-item.active::before,
.d365-sidebar.collapsed .d365-nav-group-header.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: #0d6efd;
    border-radius: 0 1px 1px 0;
    opacity: 1;
    transform: none;
    border: none;
    pointer-events: none;
    z-index: 1;
}

.d365-sidebar.collapsed .d365-nav-item:hover {
    background-color: #f9fafb;
}

.d365-sidebar.collapsed .d365-nav-group-header {
    width: 40px;
    height: 40px;
    justify-content: center;
    padding: 0;
    border-radius: 8px;
    margin: 0 auto;
    position: relative;
}

.d365-sidebar.collapsed .d365-nav-group-header:hover {
    background-color: #f9fafb;
}

/* Active module group header (collapsed + expanded) */
.d365-nav-group-header.active {
    background-color: #faf5ff;
    color: #6d28d9;
    font-weight: 600;
}

.d365-nav-group-header.active .d365-nav-icon i {
    color: #9333ea;
}

.d365-sidebar.collapsed .d365-nav-group-header.active {
    background-color: #ffffff;
    color: #0d6efd;
    box-shadow: none;
}

.d365-sidebar.collapsed .d365-nav-group-header.active .d365-nav-icon i {
    color: #0d6efd;
}

.store-module-page .d365-sidebar.collapsed .d365-nav-group-header.active,
.store-module-page .d365-nav-group-header.active {
    background-color: #f5f3ff;
    color: #5b21b6;
    box-shadow: none;
}

.store-module-page .d365-nav-group-header.active .d365-nav-icon i,
.store-module-page .d365-sidebar.collapsed .d365-nav-group-header.active .d365-nav-icon i {
    color: #7c3aed;
}

/* === Page heading card (HRM-style, below top nav in main content) === */
.d365-page-heading-wrap {
    padding: 0;
}

.d365-page-heading-card {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}

.d365-page-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.d365-page-heading-titles {
    min-width: 0;
    flex: 0 1 auto;
    width: fit-content;
    max-width: 100%;
    /* PPCT logo navy (#040C5A) — rounded right like the profile badge */
    background: linear-gradient(90deg, #040C5A 0%, #0a1a6e 48%, #002B7F 100%);
    border-radius: 8px 999px 999px 8px;
    padding: 12px 2.25rem 12px 14px;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(4, 12, 90, 0.28);
}

.d365-page-heading-breadcrumb-block {
    margin: 0 0 10px;
}

.d365-page-heading-title {
    margin: 0;
    font-family: var(--d365-form-heading-font);
    font-size: var(--d365-form-heading-size);
    line-height: 1.35;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.d365-page-heading-title-icon {
    font-size: 1.05em;
    line-height: 1;
    color: #ffffff;
    flex-shrink: 0;
}

.d365-page-heading-card.is-dashboard h1.d365-page-heading-title,
.d365-page-heading-card.is-dashboard .d365-page-heading-title {
    font-size: var(--d365-dashboard-heading-size);
    font-weight: 400;
}

@media (min-width: 1200px) {
    h1.d365-page-heading-title,
    .d365-page-heading-title {
        font-size: var(--d365-form-heading-size);
    }

    .d365-page-heading-card.is-dashboard h1.d365-page-heading-title,
    .d365-page-heading-card.is-dashboard .d365-page-heading-title {
        font-size: var(--d365-dashboard-heading-size);
    }
}

.d365-page-heading-subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.875rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.85);
}

.d365-page-heading-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.d365-page-heading-page-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
    margin-left: auto;
    margin-right: 1rem;
    align-self: center;
}

.d365-page-heading-tools-inner {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.d365-record-nav-header {
    padding: 0.15rem 0.35rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
}

.d365-page-heading-page-tools .d365-badge {
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
}

.d365-page-heading-action-group {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 7rem;
}

.d365-page-heading-action-label {
    margin: 0 0 0.15rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #4b5563;
}

.d365-page-heading-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: none;
    background: transparent;
    color: #2563eb;
    font-size: 0.875rem;
    padding: 0;
    cursor: pointer;
    position: relative;
}

.d365-page-heading-action-btn:hover {
    text-decoration: underline;
}

.d365-page-heading-action-btn .bi-chevron-down {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.d365-page-heading-action-btn .bi-chevron-down.rotated {
    transform: rotate(180deg);
}

.d365-page-heading-badge {
    position: absolute;
    top: -0.55rem;
    right: -0.35rem;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1.25rem;
    text-align: center;
}

.d365-page-heading-action-divider {
    width: 1px;
    align-self: stretch;
    min-height: 3rem;
    background: #d1d5db;
}

.d365-page-heading-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 20rem;
    max-height: 24rem;
    overflow: auto;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    z-index: 1100;
}

.d365-page-heading-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid #f3f4f6;
}

.d365-page-heading-dropdown-close {
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.15rem;
}

.d365-page-heading-dropdown-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    width: 100%;
    text-align: left;
    padding: 0.75rem 0.875rem;
    border: none;
    border-bottom: 1px solid #f9fafb;
    background: #ffffff;
    cursor: pointer;
}

.d365-page-heading-dropdown-item.unread {
    background: #eff6ff;
}

.d365-page-heading-dropdown-item strong {
    font-size: 0.875rem;
    color: #111827;
}

.d365-page-heading-dropdown-item span {
    font-size: 0.75rem;
    color: #4b5563;
    line-height: 1.35;
}

.d365-page-heading-dropdown-item small {
    font-size: 0.6875rem;
    color: #9ca3af;
}

.d365-page-heading-card.is-store .d365-page-heading-title {
    color: #ffffff;
}

@media (max-width: 768px) {
    .d365-page-heading-row {
        flex-direction: column;
        align-items: stretch;
    }

    .d365-page-heading-page-tools {
        margin-left: 0;
        margin-right: 0;
        justify-content: flex-start;
    }

    .d365-page-heading-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .d365-page-heading-action-group {
        min-width: 6.5rem;
    }

    .d365-page-heading-dropdown {
        width: min(20rem, 88vw);
    }
}

/* === Legacy header breadcrumb bar (unused) === */
.d365-header-breadcrumb-bar {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid #e5e7eb;
    padding: 8px 16px 0;
    position: sticky;
    top: var(--d365-header-height);
    z-index: 999;
}

.d365-header-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 28px;
    font-size: 12px;
    line-height: 1.3;
}

.d365-header-breadcrumb-root,
.d365-header-breadcrumb-home-link {
    display: inline-flex;
    align-items: center;
    color: #111827;
    margin-right: 2px;
    text-decoration: none;
}

.d365-page-heading-card .d365-header-breadcrumb-root,
.d365-page-heading-card .d365-header-breadcrumb-home-link {
    color: #ffffff;
}

.d365-header-breadcrumb-root i,
.d365-header-breadcrumb-home-link i {
    font-size: 13px;
}

.d365-header-breadcrumb-home-link:hover,
.d365-header-breadcrumb-home-link:focus-visible,
.d365-header-breadcrumb-home-link.active {
    color: #000000;
    text-decoration: none;
}

.d365-page-heading-card .d365-header-breadcrumb-home-link:hover,
.d365-page-heading-card .d365-header-breadcrumb-home-link:focus-visible,
.d365-page-heading-card .d365-header-breadcrumb-home-link.active {
    color: #ffffff;
}

.d365-header-breadcrumb-sep {
    font-size: 11px;
    color: #64748b;
    margin: 0 4px;
    font-weight: 700;
    opacity: 1;
}

.d365-page-heading-card .d365-header-breadcrumb-sep {
    color: #ffffff;
}

.d365-header-breadcrumb-link,
.d365-header-breadcrumb-text,
.d365-header-breadcrumb-current {
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-size: 11px;
    color: #9ca3af;
}

.d365-page-heading-card .d365-header-breadcrumb-link,
.d365-page-heading-card .d365-header-breadcrumb-text,
.d365-page-heading-card .d365-header-breadcrumb-current {
    color: #ffffff;
}

.d365-header-breadcrumb-link {
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}

.d365-header-breadcrumb-link:hover {
    color: #004578;
    text-decoration: underline;
}

.d365-page-heading-card .d365-header-breadcrumb-link:hover {
    color: #fdb913;
}

.d365-header-breadcrumb-text {
    cursor: default;
}

.d365-header-breadcrumb-accent {
    height: 3px;
    margin: 6px 0 0;
    border-radius: 2px;
    background: linear-gradient(90deg, #0078d4 0%, #1e4d78 55%, transparent 100%);
    max-width: 420px;
}

.d365-header-breadcrumb-bar.is-store .d365-header-breadcrumb-link,
.d365-page-heading-card.is-store .d365-header-breadcrumb-link {
    color: #0078d4;
}

.d365-page-heading-card.is-store .d365-header-breadcrumb-link {
    color: #ffffff;
}

.d365-header-breadcrumb-bar.is-store .d365-header-breadcrumb-link:hover,
.d365-page-heading-card.is-store .d365-header-breadcrumb-link:hover {
    color: #004578;
}

.d365-page-heading-card.is-store .d365-header-breadcrumb-link:hover {
    color: #fdb913;
}

.d365-header-breadcrumb-bar.is-store .d365-header-breadcrumb-text,
.d365-page-heading-card.is-store .d365-header-breadcrumb-text,
.d365-header-breadcrumb-bar.is-store .d365-header-breadcrumb-current,
.d365-page-heading-card.is-store .d365-header-breadcrumb-current {
    color: #9ca3af;
}

.d365-page-heading-card.is-store .d365-header-breadcrumb-text,
.d365-page-heading-card.is-store .d365-header-breadcrumb-current {
    color: #ffffff;
}

.d365-header-breadcrumb-bar.is-store .d365-header-breadcrumb-accent,
.d365-page-heading-card.is-store .d365-header-breadcrumb-accent {
    background: linear-gradient(90deg, #7c3aed 0%, #4f46e5 55%, transparent 100%);
}

.d365-page-heading-card .d365-header-breadcrumb-accent {
    background: linear-gradient(90deg, #fdb913 0%, rgba(253, 185, 19, 0.35) 55%, transparent 100%);
}

.d365-header-breadcrumb-bar.is-accounts .d365-header-breadcrumb-accent,
.d365-page-heading-card.is-accounts .d365-header-breadcrumb-accent {
    background: linear-gradient(90deg, #0078d4 0%, #1e4d78 55%, transparent 100%);
}

.d365-page-heading-card.is-accounts .d365-header-breadcrumb-accent,
.d365-page-heading-card.is-terminal .d365-header-breadcrumb-accent,
.d365-page-heading-card.is-mnr .d365-header-breadcrumb-accent,
.d365-page-heading-card.is-store .d365-header-breadcrumb-accent {
    background: linear-gradient(90deg, #fdb913 0%, rgba(253, 185, 19, 0.35) 55%, transparent 100%);
}

.d365-header-breadcrumb-bar.is-terminal .d365-header-breadcrumb-accent,
.d365-page-heading-card.is-terminal .d365-header-breadcrumb-accent {
    background: linear-gradient(90deg, #2266e3 0%, #1b52b3 55%, transparent 100%);
}

.d365-header-breadcrumb-bar.is-mnr .d365-header-breadcrumb-accent,
.d365-page-heading-card.is-mnr .d365-header-breadcrumb-accent {
    background: linear-gradient(90deg, #ca5010 0%, #8a3a0a 55%, transparent 100%);
}

.d365-sidebar.collapsed .d365-nav-group {
    width: 100%;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.d365-sidebar.collapsed .d365-nav-icon {
    width: 20px;
}

.d365-sidebar.collapsed .d365-nav-icon i {
    font-size: 18px;
}

.d365-sidebar.collapsed .d365-nav-footer {
    padding: 10px 0;
}

.d365-sidebar.collapsed .d365-nav-footer-user {
    justify-content: center;
}

.d365-sidebar.collapsed .d365-nav-footer-avatar {
    width: 32px;
    height: 32px;
}

.d365-sidebar.collapsed .d365-nav-subheader {
    display: none;
}

.d365-sidebar.collapsed .d365-nav-divider {
    margin: 6px 8px;
}

.d365-sidebar.collapsed .d365-nav-group-items .d365-nav-item {
    padding-left: 0;
}

/* Collapsed sidebar — no hover flyout tooltips (keep active left bar) */
.d365-sidebar.collapsed .d365-nav-item[title]:not(.active)::after,
.d365-sidebar.collapsed .d365-nav-group-header[title]:not(.active)::after,
.d365-sidebar.collapsed .d365-nav-item[title]:not(.active)::before,
.d365-sidebar.collapsed .d365-nav-group-header[title]:not(.active)::before {
    display: none !important;
    content: none !important;
}

.d365-sidebar.collapsed .d365-nav-item[title]:not(.active):hover::after,
.d365-sidebar.collapsed .d365-nav-item[title]:not(.active):hover::before,
.d365-sidebar.collapsed .d365-nav-group-header[title]:not(.active):hover::after,
.d365-sidebar.collapsed .d365-nav-group-header[title]:not(.active):hover::before {
    display: none !important;
    opacity: 0 !important;
}

/* === D365 Main Content Area === */
.d365-main-content {
    flex: 1;
    padding: var(--d365-spacing-lg);
    background-color: var(--d365-bg-page);
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* CRUD command bar sits directly under the top nav, above the page heading card */
.d365-main-content > .d365-command-bar {
    order: -2;
    align-self: stretch;
    flex-shrink: 0;
    width: calc(100% + (2 * var(--d365-spacing-lg)));
    max-width: none;
    margin: calc(-1 * var(--d365-spacing-lg)) calc(-1 * var(--d365-spacing-lg)) 0;
    position: relative;
    z-index: 0;
}

.d365-main-content > .d365-page-heading-wrap {
    order: -1;
    align-self: stretch;
    flex-shrink: 0;
    width: 100%;
    max-width: none;
    /* Flush to CRUD / form; 0 = +1px vs prior -1px overlap */
    margin: 0;
    padding: 0;
}

/* Form content sits flush under the page heading card */
.d365-main-content > .d365-page-heading-wrap + .row {
    --bs-gutter-y: 0;
    margin-top: 0;
}

.d365-main-content > .d365-page-heading-wrap + .row > [class*="col-"] {
    padding-top: 0;
}

/* CFS / cmf-form pages: flush under blue heading */
.d365-main-content > .d365-page-heading-wrap ~ .cmf-form {
    margin-top: 0;
    padding-top: 0;
}

/* === D365 Command Bar (Ribbon-like) === */
.d365-command-bar {
    background-color: #ffffff;
    border-bottom: 1px solid var(--d365-commandbar-border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
}

.d365-command-bar::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome/Safari */
}

.d365-command-bar-right:empty {
    display: none;
}

.d365-command-bar-left {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
}

.d365-command-bar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex: 0 0 auto;
}

/* === D365 Buttons === */
.d365-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--d365-transition);
    background-color: transparent;
    color: #4b5563; /* subtle gray */
    height: 32px;
}

.d365-btn:focus {
    outline: none;
}

.d365-btn-primary:focus {
    border-color: #10b981;
    background-color: #e6f9f3;
}

.d365-btn-success:focus {
    border-color: #10b981;
    background-color: #e6f9f3;
}

.d365-btn-danger:focus {
    border-color: #ef4444;
    background-color: #fee2e2;
}

.d365-btn-warning:focus {
    border-color: #ff8c00;
    background-color: #fff9e6;
}

.d365-btn:focus:not(.d365-btn-primary):not(.d365-btn-success):not(.d365-btn-danger):not(.d365-btn-warning) {
    border-color: #2266e3;
    background-color: #e8f0fe;
}

.d365-btn:hover:not(:disabled) {
    background-color: #f3f4f6;
    color: #111827;
}

.d365-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.d365-btn i {
    font-size: 14px;
    color: #6b7280; /* lighter gray icon */
}

.d365-btn:hover:not(:disabled) i {
    color: #374151; /* darker gray icon on hover */
}

.d365-btn-primary {
    background-color: transparent;
    color: #4b5563;
}

.d365-btn-primary i {
    color: #10b981; /* accent color if desired, or let it fall back */
}

.d365-btn-primary:hover:not(:disabled) {
    background-color: #f3f4f6;
}

.d365-btn-success {
    background-color: transparent;
    color: #4b5563;
}

.d365-btn-success i {
    color: #4b5563; /* force gray icon */
}

.d365-btn-success:hover:not(:disabled) {
    background-color: #f3f4f6;
}

.d365-btn-danger {
    color: #ef4444; /* subtle red */
    background-color: transparent;
}

.d365-btn-danger:hover:not(:disabled) {
    background-color: #fee2e2;
}

.d365-btn-icon {
    padding: 5px 7px;
    min-width: 28px;
}

.d365-btn-receipt {
    background: #fff9c4;
    border-color: #f9a825;
    color: #795548;
    font-weight: 600;
}

.d365-btn-receipt:hover:not(:disabled) {
    background: #fff176;
    border-color: #f57f17;
}

/* === D365 Cards (Form Panels) === */
.d365-card {
    background-color: var(--d365-bg-primary);
    border: 1px solid var(--d365-border);
    border-radius: var(--d365-radius-md);
    box-shadow: var(--d365-shadow-sm);
}

.d365-card-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--d365-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--d365-bg-secondary);
    border-radius: var(--d365-radius-md) var(--d365-radius-md) 0 0;
}

.d365-card-title {
    font-size: var(--d365-font-size-lg);
    font-weight: 600;
    margin: 0;
    color: var(--d365-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.d365-card-title i {
    color: var(--d365-primary);
    font-size: 16px;
}

.d365-card-body {
    padding: 14px;
}

.d365-card-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--d365-border);
    background-color: var(--d365-bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--d365-spacing-sm);
    border-radius: 0 0 var(--d365-radius-md) var(--d365-radius-md);
}

/* === D365 Form Styles === */
.d365-form-section {
    margin-bottom: var(--d365-spacing-lg);
}

.d365-form-section-title {
    font-size: var(--d365-font-size-md);
    font-weight: 600;
    color: var(--d365-primary);
    margin-bottom: var(--d365-spacing-md);
    padding-bottom: var(--d365-spacing-xs);
    border-bottom: 2px solid var(--d365-primary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.d365-form-group {
    margin-bottom: var(--d365-spacing-md);
}

.d365-form-label {
    display: block;
    font-size: var(--d365-font-size-sm);
    font-weight: 400;
    color: var(--d365-text-secondary);
    margin-bottom: 4px;
}

.d365-form-label.required::after {
    content: ' *';
    color: var(--d365-danger);
}

.d365-form-control {
    width: 100%;
    padding: 6px 10px;
    font-size: var(--d365-font-size-md);
    border: 1px solid var(--d365-border-dark);
    border-radius: var(--d365-radius-sm);
    background-color: var(--d365-bg-primary);
    transition: var(--d365-transition);
    height: 32px;
    box-sizing: border-box;
}

.d365-form-control:focus {
    outline: none;
    border-color: var(--d365-primary);
    box-shadow: 0 0 0 1px var(--d365-primary);
}

.d365-form-control:disabled {
    background-color: var(--d365-bg-tertiary);
    color: var(--d365-text-secondary);
    cursor: not-allowed;
    border-color: var(--d365-border);
}

/* Validation error styling for form controls */
.d365-form-control.validation-error {
    background-color: #fde7e9 !important;
    border-color: #a4262c !important;
}

.d365-form-control.validation-error:focus {
    box-shadow: 0 0 0 1px #a4262c !important;
}

/* Disable browser autofill/autocomplete styling */
.d365-form-control:-webkit-autofill,
.d365-form-control:-webkit-autofill:hover,
.d365-form-control:-webkit-autofill:focus,
.d365-form-control:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--d365-bg-primary) inset !important;
    -webkit-text-fill-color: var(--d365-text-primary) !important;
}

select.d365-form-control option {
    background-color: var(--d365-bg-primary);
    color: var(--d365-text-primary);
}

textarea.d365-form-control {
    height: auto;
    min-height: 60px;
}

select.d365-form-control {
    cursor: pointer;
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    appearance: menulist;
}

/* === D365 Grid/Table Styles === */
.d365-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--d365-font-size-sm);
}

.d365-grid thead {
    background-color: var(--d365-bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.d365-grid th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--d365-text-secondary);
    border-bottom: 1px solid var(--d365-border);
    white-space: nowrap;
    font-size: var(--d365-font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.d365-grid td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--d365-border-light);
    color: var(--d365-text-primary);
}

.d365-grid tbody tr {
    transition: var(--d365-transition);
}

.d365-grid tbody tr:hover {
    background-color: var(--d365-bg-secondary);
}

.d365-grid tbody tr.selected {
    background-color: var(--d365-primary-lighter);
    border-left: 3px solid var(--d365-primary);
}

.d365-grid-scroll {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--d365-border);
    border-radius: var(--d365-radius-sm);
}

/* === D365 Dashboard Tiles === */
.d365-tiles-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--d365-spacing-md);
    margin-bottom: var(--d365-spacing-lg);
}

.d365-tile {
    background-color: var(--d365-bg-primary);
    border: 1px solid var(--d365-border);
    border-radius: var(--d365-radius-md);
    padding: 14px;
    cursor: pointer;
    transition: var(--d365-transition);
    text-decoration: none;
    color: inherit;
    display: block;
}

.d365-tile:hover {
    box-shadow: var(--d365-shadow-md);
    transform: translateY(-1px);
    border-color: var(--d365-primary);
    text-decoration: none;
    color: inherit;
}

.d365-tile-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--d365-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--d365-text-inverse);
    margin-bottom: var(--d365-spacing-sm);
}

.d365-tile-icon.blue { background-color: var(--d365-primary); }
.d365-tile-icon.green { background-color: var(--d365-success); }
.d365-tile-icon.orange { background-color: var(--d365-orange); }
.d365-tile-icon.purple { background-color: #8764b8; }
.d365-tile-icon.teal { background-color: #008080; }
.d365-tile-icon.red { background-color: var(--d365-danger); }

.d365-tile-title {
    font-size: var(--d365-font-size-md);
    font-weight: 600;
    color: var(--d365-text-primary);
    margin-bottom: 2px;
}

.d365-tile-subtitle {
    font-size: var(--d365-font-size-xs);
    color: var(--d365-text-muted);
}

/* === D365 KPI Cards === */
.d365-kpi-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--d365-spacing-md);
    margin-bottom: var(--d365-spacing-lg);
}

.d365-kpi {
    background-color: var(--d365-bg-primary);
    border: 1px solid var(--d365-border);
    border-radius: var(--d365-radius-md);
    padding: 14px;
    text-align: center;
}

.d365-kpi-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--d365-primary);
    line-height: 1.1;
}

.d365-kpi-label {
    font-size: var(--d365-font-size-xs);
    color: var(--d365-text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.d365-kpi.success .d365-kpi-value { color: var(--d365-success); }
.d365-kpi.warning .d365-kpi-value { color: var(--d365-warning); }
.d365-kpi.danger .d365-kpi-value { color: var(--d365-danger); }

/* === D365 Tabs === */
.d365-tabs {
    border-bottom: 1px solid var(--d365-border);
    display: flex;
    gap: 0;
    margin-bottom: var(--d365-spacing-md);
    background-color: var(--d365-bg-secondary);
    padding: 0 var(--d365-spacing-md);
}

.d365-tab {
    padding: 10px 16px;
    color: var(--d365-text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--d365-transition);
    font-size: var(--d365-font-size-sm);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    margin-bottom: -1px;
}

.d365-tab:hover {
    color: var(--d365-primary);
}

.d365-tab.active {
    color: var(--d365-primary);
    border-bottom-color: var(--d365-primary);
    font-weight: 600;
    background-color: var(--d365-bg-primary);
}

/* === D365 Badges === */
.d365-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: var(--d365-font-size-xs);
    font-weight: 500;
    border-radius: 10px;
}

.d365-badge-primary { background-color: var(--d365-primary-lighter); color: var(--d365-primary-dark); }
.d365-badge-success { background-color: #dff6dd; color: #0b5a0b; }
.d365-badge-warning { background-color: #fff4ce; color: #8a6d3b; }
.d365-badge-danger { background-color: #fde7e9; color: #a4262c; }

/* === D365 Status Indicator === */
.d365-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--d365-font-size-sm);
}

.d365-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.d365-status-dot.active { background-color: var(--d365-success); }
.d365-status-dot.inactive { background-color: var(--d365-text-muted); }
.d365-status-dot.pending { background-color: var(--d365-warning); }
.d365-status-dot.error { background-color: var(--d365-danger); }

/* === D365 Search Box === */
.d365-search {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.d365-search-input {
    padding: 5px 8px 5px 28px;
    border: 1px solid var(--d365-border-dark);
    border-radius: var(--d365-radius-sm);
    font-size: var(--d365-font-size-sm);
    width: 180px;
    transition: var(--d365-transition);
    height: 28px;
}

.d365-search-input:focus {
    outline: none;
    border-color: var(--d365-primary);
    width: 220px;
}

.d365-search-icon {
    position: absolute;
    left: 8px;
    color: var(--d365-text-muted);
    font-size: 12px;
}

/* === D365 Record Navigation === */
.d365-record-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background-color: var(--d365-bg-primary);
    border-radius: var(--d365-radius-sm);
    border: 1px solid var(--d365-border);
}

.d365-record-nav-btn {
    padding: 3px 6px;
    background: none;
    border: none;
    border-radius: var(--d365-radius-sm);
    cursor: pointer;
    color: var(--d365-text-secondary);
    transition: var(--d365-transition);
    font-size: 11px;
}

.d365-record-nav-btn:hover:not(:disabled) {
    background-color: var(--d365-bg-secondary);
    color: var(--d365-primary);
}

.d365-record-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.d365-record-nav-status {
    font-size: var(--d365-font-size-xs);
    color: var(--d365-text-secondary);
    padding: 0 6px;
    min-width: 50px;
    text-align: center;
}

/* === D365 Page Header === */
.d365-page-header {
    margin-bottom: var(--d365-spacing-lg);
}

.d365-page-title {
    font-size: var(--d365-font-size-xl);
    font-weight: 600;
    color: var(--d365-text-primary);
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.d365-page-title i {
    color: var(--d365-primary);
}

.d365-page-subtitle {
    font-size: var(--d365-font-size-sm);
    color: var(--d365-text-muted);
    margin: 0;
}

/* === D365 Loading & Empty State === */
.d365-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.d365-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--d365-border);
    border-top-color: var(--d365-primary);
    border-radius: 50%;
    animation: d365-spin 0.7s linear infinite;
}

@keyframes d365-spin {
    to { transform: rotate(360deg); }
}

.d365-empty-state {
    text-align: center;
    padding: var(--d365-spacing-xl);
    color: var(--d365-text-muted);
}

.d365-empty-state-icon {
    font-size: 40px;
    margin-bottom: var(--d365-spacing-md);
    opacity: 0.4;
}

.d365-empty-state-title {
    font-size: var(--d365-font-size-lg);
    font-weight: 600;
    color: var(--d365-text-secondary);
    margin-bottom: 4px;
}

.d365-empty-state-text {
    font-size: var(--d365-font-size-sm);
}

/* === Utilities === */
.d365-text-primary { color: var(--d365-primary) !important; }
.d365-text-success { color: var(--d365-success) !important; }
.d365-text-warning { color: var(--d365-warning) !important; }
.d365-text-danger { color: var(--d365-danger) !important; }
.d365-text-muted { color: var(--d365-text-muted) !important; }

.d365-mt-0 { margin-top: 0 !important; }
.d365-mb-0 { margin-bottom: 0 !important; }
.d365-mt-sm { margin-top: var(--d365-spacing-sm) !important; }
.d365-mb-sm { margin-bottom: var(--d365-spacing-sm) !important; }
.d365-mt-md { margin-top: var(--d365-spacing-md) !important; }
.d365-mb-md { margin-bottom: var(--d365-spacing-md) !important; }

.d365-flex { display: flex; }
.d365-flex-1 { flex: 1; }
.d365-gap-sm { gap: var(--d365-spacing-sm); }
.d365-gap-md { gap: var(--d365-spacing-md); }
.d365-align-center { align-items: center; }
.d365-justify-between { justify-content: space-between; }
.d365-justify-end { justify-content: flex-end; }

/* === Scrollbar Styling === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--d365-bg-secondary);
}

::-webkit-scrollbar-thumb {
    background-color: var(--d365-border-dark);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--d365-text-muted);
}

/* === Mobile hamburger menu (hidden on desktop) === */
.d365-mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: 4px;
    margin-left: -4px;
    padding: 0;
    border: none;
    border-radius: var(--d365-radius-sm);
    background: transparent;
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    flex-shrink: 0;
}

.d365-mobile-menu-btn:hover,
.d365-mobile-menu-btn:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    outline: none;
}

.d365-sidebar-backdrop {
    display: none;
}

/* === Responsive === */
@media (max-width: 768px) {
    .d365-mobile-menu-btn {
        display: inline-flex;
        margin: 0;
        height: 36px;
        width: 36px;
    }

    .d365-header {
        padding: 0 12px;
        gap: 8px;
        align-items: center;
    }

    .d365-header-brand {
        min-width: 0;
        flex: 1;
        overflow: hidden;
        display: flex;
        align-items: center;
    }

    .d365-header-brand span {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .d365-header-recent {
        display: flex !important;
        margin-left: 4px;
        min-width: 0;
        flex-shrink: 1;
    }

    .d365-header-recent-desktop-only {
        display: none !important;
    }

    .d365-header-recent-item {
        width: 36px;
        height: 36px;
    }

    .d365-header-recent-chevron {
        width: 28px;
        height: 36px;
    }

    .d365-header-meta-desktop {
        display: none !important;
    }

    .d365-header-divider {
        display: none;
    }

    .d365-header-nav-desktop {
        display: none !important;
    }

    .d365-header-user {
        display: block;
    }

    .d365-header-recent-dropdown {
        right: 0;
        left: auto;
        min-width: 220px;
        max-height: 60vh;
        overflow-y: auto;
    }

    .d365-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: var(--d365-header-height) 0 0 0;
        z-index: 998;
        background: rgba(0, 0, 0, 0.45);
    }

    .d365-sidebar {
        position: fixed;
        left: -280px;
        top: var(--d365-header-height);
        height: calc(100vh - var(--d365-header-height));
        height: calc(100dvh - var(--d365-header-height));
        z-index: 999;
        width: min(280px, 85vw) !important;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.2);
        transition: left 300ms ease, width 300ms ease;
    }

    .d365-sidebar.open {
        left: 0;
    }

    .d365-sidebar.collapsed {
        left: -280px;
        width: min(280px, 85vw) !important;
    }

    .d365-sidebar.collapsed.open {
        left: 0;
        width: min(280px, 85vw) !important;
    }

    .d365-sidebar.collapsed.open .d365-nav-text,
    .d365-sidebar.collapsed.open .d365-nav-group-title,
    .d365-sidebar.collapsed.open .d365-nav-group-chevron {
        opacity: 1;
        width: auto;
        overflow: visible;
    }

    .d365-sidebar.collapsed.open .d365-nav-item {
        justify-content: flex-start;
        padding: 10px 16px;
    }

    .d365-nav-lock-btn {
        display: none;
    }

    .d365-main-content {
        padding: 12px;
    }
    
    .d365-tiles-container {
        grid-template-columns: 1fr;
    }
    
    .d365-kpi-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* === Blazor Error UI - Hidden by default === */
#blazor-error-ui {
    display: none !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #b32121;
    color: white;
    padding: 10px 16px;
    text-align: center;
    font-size: 14px;
}

#blazor-error-ui .reload {
    color: white;
    margin-left: 12px;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    margin-left: 12px;
    padding: 4px 8px;
}

/* When error occurs, Blazor will set display:block */
#blazor-error-ui[style*="display: block"],
#blazor-error-ui[style*="display:block"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* === Page Container Layout === */
.d365-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.d365-app-container {
    display: flex;
    flex: 1;
    overflow: visible;
    min-height: 0;
    position: relative;
}

.ui-theme-preview {
    border: 1px solid #e1dfdd;
    border-radius: 8px;
    overflow: hidden;
    background: var(--preview-page);
}

.ui-theme-preview-header {
    background: var(--preview-header);
    color: #fff;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 600;
}

.ui-theme-preview-body {
    display: flex;
    min-height: 160px;
    position: relative;
}

.ui-theme-preview-sidebar {
    width: 56px;
    background: var(--preview-sidebar);
    border-right: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    color: #605e5c;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 2;
}

.ui-theme-preview-content {
    width: 100%;
    padding: 14px 14px 14px 70px;
}

.ui-theme-preview-card {
    background: #fff;
    border: 1px solid #e1dfdd;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    font-size: 0.82rem;
}

.ui-theme-preview-btn {
    background: var(--preview-primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.78rem;
}

/* === D365 Tooltip Styles === */
.d365-has-tooltip {
    position: relative;
}

.d365-has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #323130;
    color: #ffffff;
    padding: 6px 10px;
    border-radius: var(--d365-radius-sm);
    font-size: var(--d365-font-size-xs);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
    pointer-events: none;
    box-shadow: var(--d365-shadow-md);
    margin-bottom: 4px;
}

.d365-has-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #323130;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1001;
    margin-bottom: -8px;
}

.d365-has-tooltip:hover::after,
.d365-has-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Tooltip positions */
.d365-tooltip-bottom::after {
    bottom: auto;
    top: 100%;
    margin-bottom: 0;
    margin-top: 4px;
}

.d365-tooltip-bottom::before {
    bottom: auto;
    top: 100%;
    border-top-color: transparent;
    border-bottom-color: #323130;
    margin-bottom: 0;
    margin-top: -8px;
}

.d365-tooltip-left::after {
    bottom: auto;
    left: auto;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-bottom: 0;
    margin-right: 4px;
}

.d365-tooltip-left::before {
    bottom: auto;
    left: auto;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-top-color: transparent;
    border-left-color: #323130;
    margin-bottom: 0;
    margin-right: -8px;
}

.d365-tooltip-right::after {
    bottom: auto;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-bottom: 0;
    margin-left: 4px;
}

.d365-tooltip-right::before {
    bottom: auto;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-top-color: transparent;
    border-right-color: #323130;
    margin-bottom: 0;
    margin-left: -8px;
}

/* Form field tooltips - for labels */
.d365-form-label.d365-has-tooltip {
    cursor: help;
}

.d365-form-label.d365-has-tooltip::after {
    max-width: 250px;
    white-space: normal;
    text-align: left;
}

/* Required field indicator with tooltip */
.d365-form-label.required::after {
    content: ' *';
    color: var(--d365-danger);
}

/* Validation error tooltip */
.d365-validation-error {
    color: var(--d365-danger);
    font-size: var(--d365-font-size-xs);
    margin-top: 2px;
}

/* Field with validation error */
.d365-field-error .d365-form-control {
    border-color: var(--d365-danger) !important;
    background-color: #fde7e9 !important;
}

/* Permission-based field styling */
.d365-field-readonly .d365-form-control {
    background-color: var(--d365-bg-tertiary) !important;
    cursor: not-allowed;
}

.d365-field-hidden {
    display: none !important;
}

/* Info icon for help */
.d365-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--d365-info);
    color: white;
    font-size: 10px;
    margin-left: 4px;
    cursor: help;
}

/* === D365 AutoComplete Select Component === */
.autocomplete-select {
    position: relative;
    display: inline-block;
    width: 100%;
}

.autocomplete-select.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.autocomplete-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.autocomplete-input {
    flex: 1;
    padding-right: 28px !important;
}

.autocomplete-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 26px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--d365-text-secondary);
    border-radius: 0 var(--d365-radius-sm) var(--d365-radius-sm) 0;
    transition: var(--d365-transition);
}

.autocomplete-toggle:hover {
    background-color: var(--d365-bg-secondary);
    color: var(--d365-primary);
}

.autocomplete-toggle i {
    font-size: 10px;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--d365-bg-primary);
    border: 1px solid var(--d365-primary);
    border-top: none;
    border-radius: 0 0 var(--d365-radius-md) var(--d365-radius-md);
    box-shadow: var(--d365-shadow-lg);
    max-height: 250px;
    overflow-y: auto;
    margin-top: -1px;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--d365-border-light);
    transition: background-color 0.1s;
    font-size: var(--d365-font-size-sm);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background-color: var(--d365-bg-secondary);
}

.autocomplete-item.selected {
    background-color: var(--d365-primary-lighter);
    font-weight: 500;
}

.autocomplete-item-text {
    color: var(--d365-text-primary);
}

.autocomplete-no-results {
    padding: 12px;
    text-align: center;
    color: var(--d365-text-muted);
    font-style: italic;
    font-size: var(--d365-font-size-sm);
}

/* Two-line item template styling */
.autocomplete-item-two-line {
    line-height: 1.3;
}

.autocomplete-item-two-line .primary {
    display: block;
    font-weight: 600;
    color: var(--d365-text-primary);
}

.autocomplete-item-two-line .secondary {
    display: block;
    font-size: var(--d365-font-size-xs);
    color: var(--d365-text-muted);
    margin-top: 2px;
}

/* === D365 AutoSuggest Input Component === */
.autosuggest-input {
    position: relative;
    width: 100%;
}

.autosuggest-input.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.autosuggest-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--d365-bg-primary);
    border: 1px solid var(--d365-border-dark);
    border-top: none;
    border-radius: 0 0 var(--d365-radius-md) var(--d365-radius-md);
    box-shadow: var(--d365-shadow-lg);
    max-height: 200px;
    overflow-y: auto;
}

.autosuggest-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--d365-border-light);
    transition: background-color 0.1s;
    font-size: var(--d365-font-size-sm);
}

.autosuggest-item:last-child {
    border-bottom: none;
}

.autosuggest-item:hover,
.autosuggest-item.highlighted {
    background-color: var(--d365-bg-secondary);
}

/* End of AutoComplete styles */
