/* ============================================
   Aspen Blazor UI - Global Styles
   Design tokens from Evergreen design system
   ============================================ */

:root {
    --aspen-primary: #1976d2;
    --aspen-primary-light: #90caf9;
    --aspen-primary-dark: #181F2A;
    --aspen-accent: #2371E7;
    --aspen-bg-light: #F9F9FA;
    --aspen-bg-dark: #121212;
    --aspen-paper-light: #ffffff;
    --aspen-paper-dark: #1e1e1e;
    --aspen-success: #2e7d32;
    --aspen-error: #d32f2f;
    --aspen-error-badge: #f44336;
    --aspen-warning: #ed6c02;
    --aspen-info: #0288d1;
    --aspen-text-heading: #1F292E;
    --aspen-text-description: #33444D;
    --aspen-text-subheading: #5C7A8A;
    --aspen-font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --aspen-font-size-base: 14px;
    --aspen-navbar-height: 48px;
    --aspen-sidebar-width: 210px;
    --aspen-sidebar-collapsed-width: 52px;
    --aspen-statusbar-height: 28px;
    --aspen-tab-indicator: #2371E7;
    --aspen-sidebar-bg: #f0f2f5;
    --aspen-sidebar-bg-dark: #1a1d23;
    --aspen-border-light: rgba(0, 0, 0, 0.12);
    --aspen-border-dark: rgba(255, 255, 255, 0.12);
}

/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--aspen-font-family);
    font-size: var(--aspen-font-size-base);
    height: 100%;
    overflow: hidden;
}

/* ── Global MudBlazor Overrides ── */

/* MudBlazor defaults buttons and tabs to text-transform: uppercase.
   We disable it globally so no component needs a per-instance override.
   Theme Typography.Button.TextTransform only affects MudText Typo="button",
   not actual MudButton/MudTab components — hence the CSS overrides. */
.mud-button-root,
.mud-tab {
    text-transform: none;
}

/* ── Utility Classes ── */


.text-ellipsis {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-nowrap {
    flex-shrink: 0;
    white-space: nowrap;
}

.loading-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    flex: 1;
}

.empty-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    min-height: 200px;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI5MC4xOCA3NS44MzkyQzI5MS41OCA3Ny4yMzkyIDI5MS41OCA3OS40NjsyIDI5MC4xOCA4MC44NjU4TDI2Ni42MDYgMTA0LjQ0QzI2NS44MTMgMTA1LjIyNCAyNjQuNzE3IDEwNS43MDggMjYzLjUwNiAxMDUuNzA4TDI1NC41MDYgMTA1LjcwOEMyNTQuMTY1IDEwNS43MDggMjUzLjg0OSAxMDUuNjA5IDI1My41NjcgMTA1LjQ0QzI1MS45NzcgMTA0LjQ4OSAyNTEuOTc3IDEwMS40OTggMjUzLjU2NyA5OS45MDNMMjcwLjc1IDgyLjcyMDRIMjM4LjkzNEMyMzYuNjk3IDgyLjcyMDQgMjM1IDgxLjMyOTcgMjM1IDc5LjMwMDRWNzQuNDA0NEMyMzUgNzIuMzc1IDIzNi42OTcgNzAuOTg0NCAyMzguOTM0IDcwLjk4NDRIMjcwLjc1TDI1My41NjcgNTMuODAyNEMyNTEuOTc3IDUyLjIwNjQgMjUxLjk3NyA0OS4yMTY0IDI1My41NjcgNDcuNjIwNEMyNTMuODQ5IDQ3LjQ1MTQgMjU0LjE2NSA0Ny4zNTI0IDI1NC41MDYgNDcuMzUyNEgyNjMuNTA2WiIgZmlsbD0iI0ZGRDIwMCIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9nPjwvc3ZnPg==) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* ── Scrollbar Styling ── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.35);
}

/* ── App Shell Layout ── */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Note: sidebar layout is now a two-panel design (activity bar + tree panel)
   controlled by .app-sidebar-container in SidebarNav.razor scoped styles */

.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.app-content-body {
    flex: 1;
    overflow: auto;
    padding: 16px 24px;
}

/* Full-bleed pages (e.g. POS) fill the entire content area */
.app-content-body.full-bleed {
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* (Module buttons removed -- replaced by activity bar in SidebarNav scoped styles) */

/* ── Sidebar Navigation Tree ── */
.sidebar-nav-tree {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 0;
}

/* Tree items */
.sidebar-nav-tree .mud-treeview-item-content {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
    min-height: 30px !important;
}

.sidebar-nav-tree .mud-treeview-item-label {
    font-size: 0.8125rem;
}

.sidebar-nav-tree .mud-treeview-item-icon {
    font-size: 17px !important;
}

.sidebar-nav-tree .mud-treeview-item-arrow .mud-icon-root {
    font-size: 16px;
}

/* ── Navbar Message Badge ── */
.navbar-badge-wrapper {
    position: relative;
    display: inline-flex;
}

.navbar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background-color: var(--aspen-error-badge);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
    z-index: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ── Status Bar ── */
.status-bar {
    display: flex;
    align-items: center;
    height: var(--aspen-statusbar-height);
    padding: 0 12px;
    font-size: 0.6875rem;
    gap: 16px;
    border-top: 1px solid var(--aspen-border-light);
    flex-shrink: 0;
}

.dark-mode .status-bar {
    border-top-color: var(--aspen-border-dark);
}

.status-bar .status-item {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.status-bar .status-version {
    font-family: 'Cascadia Code', 'Consolas', monospace;
}

.status-bar .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-bar .status-dot.online {
    background-color: var(--aspen-success);
}

.status-bar .status-dot.offline {
    background-color: var(--aspen-error);
}

.status-bar .status-spacer {
    flex: 1;
}

/* ── Tab Bar ── */
.tab-bar {
    border-bottom: 1px solid var(--aspen-border-light);
    flex-shrink: 0;
}

.dark-mode .tab-bar {
    border-bottom-color: var(--aspen-border-dark);
}

.tab-bar .mud-tab {
    font-weight: 500;
    font-size: 0.8125rem;
    letter-spacing: normal;
    min-height: 36px;
}

/* Close button on tabs — subtle by default, visible on hover */
.tab-bar .mud-dynamic-tab-close-icon {
    opacity: 0.4;
    transition: opacity 0.15s ease;
    margin-left: 4px;
}

.tab-bar .mud-tab:hover .mud-dynamic-tab-close-icon {
    opacity: 0.9;
}

/* Hide the add-tab button (tabs are opened via sidebar navigation) */
.tab-bar .mud-dynamic-tab-header .mud-icon-button {
    display: none;
}

/* ── Placeholder Page ── */
.placeholder-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    opacity: 0.5;
}

.placeholder-page .placeholder-icon {
    font-size: 64px;
}

/* ── Dashboard Cards ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 8px 0;
}

.welcome-banner {
    padding: 32px 36px;
    border-radius: 12px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--aspen-primary-dark) 0%, var(--aspen-primary) 100%);
    color: white;
}

/* Subtle pattern overlay on the banner */
.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    pointer-events: none;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    bottom: -30%;
    right: 10%;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    pointer-events: none;
}

.welcome-banner-title {
    color: white;
    font-weight: 600;
}

.welcome-banner-subtitle {
    color: rgba(255, 255, 255, 0.8);
}

.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 24px;
}

/* ── Quick Action Buttons (inside welcome banner) ── */
.quick-action-btn.mud-button-filled {
    background-color: rgba(255, 255, 255, 0.95) !important;
    color: var(--aspen-text-heading) !important;
    justify-content: flex-start;
    font-weight: 500;
    font-size: 0.8125rem;
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.quick-action-btn.mud-button-filled .mud-icon-root {
    color: var(--aspen-primary) !important;
}

.quick-action-btn.mud-button-filled:hover {
    background-color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transform: translateY(-1px);
}

/* ── NavBar Logo ── */
.navbar-logo {
    height: 28px;
    width: auto;
}

/* ── NavBar Search Container ── */
.navbar-search-container {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 0 12px;
    max-width: 350px;
    width: 100%;
    margin-right: 8px;
    transition: background 0.2s ease;
}

.navbar-search-container:focus-within {
    background: rgba(255, 255, 255, 0.18);
}

.navbar-search-container:hover {
    background: rgba(255, 255, 255, 0.14);
}

.navbar-search-container .navbar-search {
    margin: 0 !important;
}

.navbar-search-container .navbar-search .mud-input {
    color: white !important;
    font-size: 0.875rem;
}

.navbar-search-container .navbar-search .mud-input-underline::before,
.navbar-search-container .navbar-search .mud-input-underline::after {
    border-bottom: none !important;
}

.navbar-search-container .navbar-search .mud-input-adornment .mud-icon-root {
    color: rgba(255, 255, 255, 0.7) !important;
}

.navbar-search-container .navbar-search input::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* ── Dark mode scrollbar overrides ── */
.dark-mode ::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
}

.dark-mode ::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.35);
}

/* (Old sidebar collapsed/divider styles removed -- now handled by tree-panel.collapsed) */

/* ══════════════════════════════════════════════
   Invoice Selection Page Styles
   ══════════════════════════════════════════════ */

/* When the Invoice Selection page is present, switch the content body from
   a scrollable container to a constrained flex container so descendants
   can fill remaining space instead of overflowing. */
.app-content-body:has(.inv-sel-page) {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Page root — MudStack already provides display:flex + flex-direction:column.
   We add flex:1 so it fills the content body and min-height:0 so it
   doesn't grow beyond the container. */
.inv-sel-page {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Criteria panel header — MudStack handles flex layout; we add interactive styles */
.inv-sel-criteria-header {
    padding: 8px 16px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.inv-sel-criteria-header:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.dark-mode .inv-sel-criteria-header:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

/* Tabs inside criteria */
.inv-sel-tabs .mud-tabs-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.inv-sel-tabs .mud-tabs-panels,
.inv-sel-tabs .mud-tabpanel {
    overflow: visible;
}

.inv-sel-tabs .mud-tab {
    font-weight: 500;
    font-size: 0.8125rem;
    letter-spacing: normal;
    min-height: 38px;
    padding: 0 20px;
}

/* Range field group */
.inv-sel-range-group {
    padding-top: 2px;
}

/* Align mixed control types in Invoice Selection row 2 */
.inv-sel-row2-item {
    display: flex;
    align-items: flex-end;
}

.inv-sel-row2-item > * {
    width: 100%;
}

.inv-sel-row2-checkbox {
    margin-bottom: 4px;
    transform: translateY(1px);
}

/* Results bar — MudStack handles flex; we add minimal padding */
.inv-sel-results-bar {
    padding: 4px 4px;
}

/* ── Expandable Search Bar ── */
.aspen-expandable-search {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 300px;
}

.aspen-expandable-search:focus-within {
    width: 800px;
}

.inv-sel-criteria-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-inline-size: 0;
}

.inv-sel-criteria-fieldset:disabled {
    opacity: 0.45;
    pointer-events: none;
}


/* Action bar — MudPaper provides surface; we add border and subtle background */
.inv-sel-action-bar {
    padding: 4px 8px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.01);
}

.dark-mode .inv-sel-action-bar {
    background-color: rgba(255, 255, 255, 0.015);
}

/* Grid container — fills all remaining vertical space via flexbox chain:
   app-content-body → inv-sel-page → inv-sel-grid-container → mud-table → mud-table-container.
   Same pattern as POS .items-grid. */
.inv-sel-grid-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.inv-sel-grid-container .mud-table {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.inv-sel-grid-container .mud-table-container {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.inv-sel-grid-container .mud-table-head .mud-table-cell {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--aspen-text-subheading);
    padding-top: 6px;
    padding-bottom: 6px;
}

.inv-sel-grid-container .mud-table-body .mud-table-cell {
    font-size: 0.8125rem;
    padding-top: 4px;
    padding-bottom: 4px;
}

/* Row hover effect */
.inv-sel-grid-row {
    transition: background-color 0.1s ease;
}

/* ── Shared DataGrid Layout Improvements ──────────────────────────────────── */

/* 1. Compact grouping drop zone — reduce the large empty area */
.mud-datagrid .mud-drop-zone {
    min-height: 28px !important;
    padding: 4px 12px !important;
    font-size: 0.75rem;
    opacity: 0.5;
    border: 1px dashed var(--mud-palette-lines-default);
    border-radius: 4px;
    margin: 4px 8px;
}

.mud-datagrid .mud-drop-zone:empty::before {
    content: "Drag a column header here to group";
    font-size: 0.72rem;
    color: var(--mud-palette-text-secondary);
}

/* 2. Compact inline filter row — reduce height, hide operator, hover-reveal clear */
.mud-datagrid .mud-table-head tr:last-child .mud-table-cell {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
}

.mud-datagrid .mud-table-head .mud-input {
    font-size: 0.75rem !important;
    margin-top: 0 !important;
}

.mud-datagrid .mud-table-head .mud-input-control {
    margin-top: 0 !important;
}

.mud-datagrid .mud-table-head .mud-input .mud-input-slot,
.mud-datagrid .mud-table-head .mud-input input {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
    font-size: 0.75rem !important;
}

/* Filter row buttons removed via ShowFilterIcon="false" on columns */

/* 3. Tighter column header alignment */
.mud-datagrid .mud-table-head .mud-table-cell {
    padding-left: 8px !important;
    padding-right: 8px !important;
    white-space: nowrap;
}

.mud-datagrid .mud-table-body .mud-table-cell {
    padding-left: 8px !important;
    padding-right: 8px !important;
}

/* 4. Settings/column menu icon — integrate better with grid chrome */
.mud-datagrid .mud-menu .mud-icon-button {
    padding: 4px !important;
    width: 28px !important;
    height: 28px !important;
}

.mud-datagrid .mud-menu .mud-icon-button .mud-icon-root {
    font-size: 1rem !important;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

.mud-datagrid .mud-menu .mud-icon-button:hover .mud-icon-root {
    opacity: 1;
}

/* Bottom bar — MudPaper provides surface; left-aligned via MudStack */
.inv-sel-bottom-bar {
    padding: 6px 8px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
}

.inv-sel-bottom-divider {
    margin: 0 4px !important;
    height: 18px !important;
    align-self: center;
    opacity: 0.45;
}

.inv-sel-bottom-bar .mud-select {
    max-width: 100%;
}

/* ══════════════════════════════════════════════
   Customer Selection Page Styles
   ══════════════════════════════════════════════ */

.app-content-body:has(.cust-sel-page) {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cust-sel-page {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.cust-sel-grid-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
}

.cust-sel-grid-container .mud-table {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cust-sel-grid-container .mud-table-container {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.cust-sel-grid-container .mud-table-head .mud-table-cell {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--aspen-text-subheading);
    padding-top: 6px;
    padding-bottom: 6px;
}

.cust-sel-grid-container .mud-table-body .mud-table-cell {
    font-size: 0.8125rem;
    padding-top: 4px;
    padding-bottom: 4px;
}

/* ══════════════════════════════════════════════
   Customer Entry Layout (Rail & Scroll Spy)
   ══════════════════════════════════════════════ */
.app-content-body:has(.cust-entry-page) {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.cust-entry-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.cust-entry-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background-color: var(--aspen-bg-light);
    margin-top: 8px;
    border-top: 1px solid var(--mud-palette-lines-default);
}
.dark-mode .cust-entry-layout { background-color: var(--aspen-bg-dark); }

.cust-entry-rail {
    width: 240px;
    flex-shrink: 0;
    border-left: 1px solid var(--mud-palette-lines-default);
    overflow-y: auto;
    padding: 16px 0;
    background-color: var(--aspen-paper-light);
}
.dark-mode .cust-entry-rail { background-color: var(--aspen-paper-dark); }

.cust-entry-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px 64px 32px;
    scroll-behavior: smooth;
}

.cust-entry-section {
    margin-bottom: 32px;
    scroll-margin-top: 24px;
}

.cust-entry-card {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    background-color: var(--aspen-paper-light);
}
.dark-mode .cust-entry-card { background-color: var(--aspen-paper-dark); }

.cust-entry-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--mud-palette-lines-default);
    background: var(--aspen-paper-light);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.dark-mode .cust-entry-footer { background: var(--aspen-paper-dark); }

.cust-entry-rail .mud-list-item {
    border-radius: 16px 0 0 16px;
    margin-left: 16px;
    margin-bottom: 2px;
}
.cust-entry-rail .mud-list-item.mud-selected-item {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.1);
    color: var(--mud-palette-primary);
    font-weight: 600;
}
.cust-entry-rail .mud-list-item.mud-selected-item .mud-icon-root {
    color: var(--mud-palette-primary) !important;
}

/* ══════════════════════════════════════════════
   Customer Dashboard Page Styles
   ══════════════════════════════════════════════ */

/* When the Customer Dashboard is present, switch the content body from
   a scrollable container to a constrained flex container. */
.app-content-body:has(.cust-dash-page) {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.cust-dash-page {
    flex: 1;
    min-height: 0;
    padding: 4px 2px 16px 2px;
    position: relative;
}

/* Widget card — subtle lift on hover */
.aspen-widget {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.aspen-widget:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.12);
}

.dark-mode .aspen-widget:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.12);
}

/* Widget header */
.aspen-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    background-color: rgba(0, 0, 0, 0.015);
}

.dark-mode .aspen-widget-header {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Header icon — tinted circle background */
.aspen-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
}

.aspen-header-icon--primary {
    background-color: rgba(25, 118, 210, 0.1);
}

.aspen-header-icon--warning {
    background-color: rgba(255, 152, 0, 0.1);
}

.aspen-header-icon--success {
    background-color: rgba(56, 142, 60, 0.1);
}

.aspen-header-icon--info {
    background-color: rgba(2, 136, 209, 0.1);
}

.aspen-header-icon--error {
    background-color: rgba(211, 47, 47, 0.1);
}

/* Warning-tinted header for credit hold */
.aspen-widget-header--warning {
    background-color: rgba(211, 47, 47, 0.04);
}

.dark-mode .aspen-widget-header--warning {
    background-color: rgba(211, 47, 47, 0.08);
}

/* Widget body — scrollable list area (reduced to fit 2 rows on 1080p) */
.aspen-widget-body {
    flex: 1;
    overflow-y: auto;
    max-height: 310px;
}

/* AR Lookup needs min-height so it matches neighbors when empty */
.aspen-widget-body--ar {
    min-height: 310px;
}

/* Widget footer — View All link area */
.aspen-widget-footer {
    padding: 6px 16px;
    border-top: 1px solid var(--mud-palette-lines-default);
    text-align: center;
}

.aspen-widget-footer a,
.aspen-widget-footer button {
    font-size: 0.75rem;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.aspen-widget-footer:hover a,
.aspen-widget-footer:hover button {
    opacity: 1;
}

/* List items inside widgets — stronger hover */
.cust-dash-list-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: background-color 0.15s ease;
    position: relative;
}

.cust-dash-list-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--mud-palette-primary);
    opacity: 0;
    transition: opacity 0.15s ease;
    border-radius: 0 2px 2px 0;
}

.cust-dash-list-item:hover {
    background-color: rgba(25, 118, 210, 0.04) !important;
}

.cust-dash-list-item:hover::before {
    opacity: 1;
}

.cust-dash-list-item:last-child {
    border-bottom: none;
}

.dark-mode .cust-dash-list-item {
    border-bottom-color: rgba(255, 255, 255, 0.04);
}

.dark-mode .cust-dash-list-item:hover {
    background-color: rgba(25, 118, 210, 0.08) !important;
}

/* Customer IDs — monospace for scannability */
.cust-id {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    opacity: 0.65;
}

/* Currency amounts — monospace, right-aligned */
.cust-amount {
    font-weight: 600;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.8rem;
    white-space: nowrap;
}

.cust-amount--large {
    color: var(--mud-palette-warning-darken);
}

.cust-amount--danger {
    color: var(--mud-palette-error);
}

/* Credit Hold progress bar */
.cust-credit-bar {
    height: 4px;
    border-radius: 2px;
    background-color: rgba(0, 0, 0, 0.06);
    overflow: hidden;
    margin-top: 4px;
    width: 100%;
}

.dark-mode .cust-credit-bar {
    background-color: rgba(255, 255, 255, 0.1);
}

.cust-credit-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* Revenue bar for Top Customers */
.cust-revenue-bar {
    height: 3px;
    border-radius: 2px;
    background-color: rgba(0, 0, 0, 0.04);
    overflow: hidden;
    margin-top: 2px;
}

.dark-mode .cust-revenue-bar {
    background-color: rgba(255, 255, 255, 0.08);
}

.cust-revenue-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--mud-palette-warning), var(--mud-palette-warning-lighten));
    transition: width 0.5s ease;
}

/* Recently Viewed time ring on avatar */
.cust-avatar-ring {
    border-radius: 50%;
    padding: 2px;
    display: inline-flex;
}

.cust-avatar-ring--fresh {
    box-shadow: 0 0 0 2px rgba(56, 142, 60, 0.6);
}

.cust-avatar-ring--recent {
    box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.5);
}

.dark-mode .cust-avatar-ring--fresh {
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.7);
}

.dark-mode .cust-avatar-ring--recent {
    box-shadow: 0 0 0 2px rgba(255, 167, 38, 0.6);
}

/* Skeleton loading shimmer */
.aspen-skeleton-row {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    gap: 12px;
}

.aspen-skeleton-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    flex-shrink: 0;
}

.aspen-skeleton-line {
    height: 10px;
    border-radius: 4px;
    background: linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.aspen-skeleton-line--short {
    width: 60%;
}

.aspen-skeleton-line--long {
    width: 85%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.dark-mode .aspen-skeleton-circle,
.dark-mode .aspen-skeleton-line {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ── AspenLoadingOverlay shared styles ── */
/* Overlay mode now uses MudOverlay (Absolute, LightBackground/DarkBackground).
   This class adds backdrop-filter blur on top of MudOverlay's native backdrop. */
.aspen-loading-overlay {
    backdrop-filter: blur(2px);
}

.aspen-loading-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}

/* Refreshed timestamp */
.cust-dash-refresh {
    font-size: 0.72rem;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

.cust-dash-refresh:hover {
    opacity: 0.8;
}

/* Compact list item padding */
.aspen-widget .mud-list-item {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    min-height: 40px !important;
}

/* Empty widget state */
.aspen-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    opacity: 0.45;
    gap: 8px;
}

.dark-mode .aspen-empty-state {
    opacity: 0.55;
}

/* ── KPI Summary Cards ── */
/* MudPaper provides the surface; MudStack handles flex layout inside each card */
.aspen-kpi-card {
    flex: 1;
    min-width: 140px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    padding: 12px 16px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.aspen-kpi-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.12);
}

.dark-mode .aspen-kpi-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.12);
}

/* KPI icon — tinted circle (reuses .cust-dash-header-icon--{color} backgrounds) */
.aspen-kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* KPI card with alert tint (credit hold) */
.aspen-kpi-card--alert {
    border-color: rgba(211, 47, 47, 0.2);
    background-color: rgba(211, 47, 47, 0.02);
}

.dark-mode .aspen-kpi-card--alert {
    border-color: rgba(211, 47, 47, 0.3);
    background-color: rgba(211, 47, 47, 0.05);
}

/* ═════════════════════════════════════════════════════════════
   POS Workspace
   ═════════════════════════════════════════════════════════════ */

.pos-workspace {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── POS Toolbar ── */
.pos-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.015) 0%, rgba(0, 0, 0, 0.005) 100%);
    flex-shrink: 0;
    gap: 8px;
    min-height: 44px;
    flex-wrap: nowrap;
}

.pos-toolbar-left {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
}

.pos-toolbar-right {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
    white-space: nowrap;
    flex-shrink: 0;
}

.pos-part-search {
    max-width: 300px;
    min-width: 160px;
    flex: 0 1 260px;
}

/* ── POS Body (main + drawer) ── */
.pos-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.pos-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

.pos-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 32px;
    text-align: center;
}

.pos-empty-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.pos-recent-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Invoice Sub-Tab Bar ── */
.pos-tab-bar {
    flex-shrink: 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.pos-tab-bar .mud-tabs-toolbar {
    min-height: 34px;
}

.pos-tab-bar .mud-tab {
    font-weight: 500;
    font-size: 0.8125rem;
    letter-spacing: normal;
    min-height: 34px;
    padding: 0 16px;
}

.pos-tab-bar .mud-dynamic-tab-close-icon {
    opacity: 0.4;
    transition: opacity 0.15s ease;
    margin-left: 4px;
}

.pos-tab-bar .mud-tab:hover .mud-dynamic-tab-close-icon {
    opacity: 0.9;
}

/* Hide the empty panels area — we render InvoiceEditor outside the tabs */
.pos-tab-bar .mud-tabs-panels {
    display: none !important;
}

/* ── Invoice Editor Layout ── */
.invoice-editor {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── Invoice Header ── */
.invoice-header {
    padding: 6px 12px 4px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    background: linear-gradient(180deg, rgba(0,0,0,0.018) 0%, rgba(0,0,0,0.005) 100%);
    flex-shrink: 0;
}

.inv-hdr-doc-type-text {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    color: var(--mud-palette-text-primary);
}

/* Let MudBlazor render fields at natural Dense size — matches Search parts field */

.dark-mode .pos-toolbar {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0.01) 100%);
}

.dark-mode .invoice-header {
    background: linear-gradient(180deg, rgba(255,255,255,0.025) 0%, rgba(255,255,255,0.01) 100%);
}

.dark-mode .items-toolbar {
    background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.005) 100%);
}

.dark-mode .invoice-totals-bar {
    background: linear-gradient(0deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
    box-shadow: 0 -1px 4px rgba(0,0,0,0.15);
}

.dark-mode .items-grid .mud-table-container {
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 39px,
        rgba(255,255,255,0.02) 39px,
        rgba(255,255,255,0.02) 40px
    );
}

/* (address row background override removed) */

/* (dark mode header handled by .invoice-header rule above) */

/* ── Invoice Content (Tabbed) ── */
.invoice-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.invoice-content .mud-tabs {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.invoice-content .mud-tabs-toolbar {
    min-height: 34px;
}

.invoice-content .mud-tab {
    font-weight: 500;
    font-size: 0.8125rem;
    letter-spacing: normal;
    min-height: 34px;
    padding: 0 16px;
}

.invoice-content .mud-tabs-panels {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* MudTabPanel wrapper — must fill and propagate flex */
.invoice-content .mud-tabs-panels > .mud-tabpanel {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.invoice-tab-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ── Items Tab ── */
.invoice-items-tab {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Items Toolbar ── */
.items-toolbar {
    padding: 3px 10px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    background: linear-gradient(180deg, rgba(0,0,0,0.015) 0%, rgba(0,0,0,0.003) 100%);
    flex-shrink: 0;
}

/* MudDataGrid must fill remaining vertical space */
.items-grid {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.items-grid.mud-table {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.items-grid .mud-table-container {
    flex: 1;
    min-height: 0;
    overflow: auto;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 39px,
        rgba(0,0,0,0.02) 39px,
        rgba(0,0,0,0.02) 40px
    );
}

/* Center the "no records" content vertically */
.items-grid .mud-table-container table {
    height: 100%;
}

/* Subtle row hover */
.items-grid .mud-table-row:hover {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.04) !important;
}

/* ── Orders Tab ── */
.invoice-orders-tab {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.orders-toolbar {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    gap: 4px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    flex-shrink: 0;
}

/* ── Comments Tab ── */
.invoice-comments-tab {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 12px;
}

.comment-section {
    display: flex;
    flex-direction: column;
}

.comment-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.comment-editor {
    flex: 1;
}

/* ── Shipping Tab ── */
.invoice-shipping-tab {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

/* ── Totals Bar ── */
/* ── Invoice Totals Bar ── */
.invoice-totals-bar {
    padding: 8px 12px;
    border-top: 2px solid var(--mud-palette-lines-default);
    background: linear-gradient(0deg, rgba(0,0,0,0.025) 0%, rgba(0,0,0,0.008) 100%);
    flex-shrink: 0;
    box-shadow: 0 -1px 4px rgba(0,0,0,0.04);
}

/* ── POS responsive refinements ── */
/* (MudGrid handles responsiveness via xs/sm/md breakpoints) */

/* Keyboard shortcut hints */
.shortcut-hint {
    font-size: 0.6rem;
    opacity: 0.5;
    margin-left: 4px;
    padding: 1px 4px;
    border: 1px solid currentColor;
    border-radius: 3px;
    line-height: 1;
    vertical-align: middle;
}

/* ── Shared Tool Drawer (base for all drawers) ── */
.aspen-tool-drawer {
    width: 320px;
    min-width: 320px;
    border-left: 1px solid var(--mud-palette-lines-default);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

@media (max-width: 960px) {
    .aspen-tool-drawer {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 1200;
        background: var(--mud-palette-surface);
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
    }
}

/* POS drawer override (narrower than default) */
.pos-tool-drawer {
    width: 300px;
    min-width: 300px;
}

/* ── Part Lookup Body (main + drawer flex layout) ── */
.part-lookup-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.part-lookup-main {
    flex: 1;
    min-width: 0;
    overflow: auto;
}

/* ── Unit Lookup Body (main + drawer flex layout) ── */
.unit-lookup-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.unit-lookup-main {
    flex: 1;
    min-width: 0;
    overflow: auto;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    flex-shrink: 0;
}

.drawer-tabs {
    padding: 8px;
    flex-shrink: 0;
}

.drawer-content {
    flex: 1;
    overflow: auto;
}

.drawer-list {
    padding: 0 !important;
}

.drawer-doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
}

.drawer-doc-label {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.drawer-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
}

.drawer-search {
    padding: 12px;
}

/* ── Notification Bar ─────────────────────────────────────── */

.aspen-notification-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px 16px;
    min-height: 32px;
    background: rgba(255, 152, 0, 0.06);
    border-bottom: 1px solid rgba(255, 152, 0, 0.15);
}

.aspen-notification-chip {
    cursor: pointer;
    font-size: 0.75rem;
}

/* ── Part Lookup — Stock Bar ─────────────────────────────── */

.part-stock-bar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.06);
}

.dark-mode .part-stock-bar {
    background-color: rgba(255, 255, 255, 0.08);
}

.part-stock-segment--available {
    background: var(--mud-palette-success);
    transition: width 0.4s ease;
}

.part-stock-segment--committed {
    background: var(--mud-palette-warning);
    transition: width 0.4s ease;
}

.part-stock-segment--onorder {
    background: var(--mud-palette-info);
    transition: width 0.4s ease;
}

.part-stock-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.part-stock-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
}

.part-stock-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Part Lookup — Image Placeholder ─────────────────────── */

.part-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    border: 2px dashed var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 24px;
    gap: 8px;
}

.dark-mode .part-image-placeholder {
    border-color: rgba(255, 255, 255, 0.12);
}

/* ── Unit Lookup — Image Placeholder ─────────────────────── */

.unit-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    border: 2px dashed var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 24px;
    gap: 4px;
    background: linear-gradient(180deg, rgba(25, 118, 210, 0.06), rgba(25, 118, 210, 0.01));
}

.dark-mode .unit-image-placeholder {
    border-color: rgba(255, 255, 255, 0.12);
}

/* ── Dashboard — Expandable Search Bar ────────────────────── */

.dash-search-bar {
    width: 200px;
    transition: width 0.3s ease;
}

.dash-search-bar.mud-input-control--active,
.dash-search-bar:focus-within {
    width: 360px;
}
