:root {
    --app-bg: #f6f7fb;
    --app-fg: #0f172a;
    --muted: #64748b;
    --card-bg: #ffffff;
    --card-border: #e5e7eb;
    --card-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
    --link: #006bb7;
    --primary: #1b6ec2;
    --primary-border: #1861ac;
    --focus: #258cfb;
    --sidebar-bg: #ffffff;
    --sidebar-top-bg: rgba(15, 23, 42, 0.03);
    --sidebar-border: rgba(15, 23, 42, 0.10);
    --sidebar-link: #0f172a;
    --sidebar-link-hover: #0f172a;
    --sidebar-link-active: #0f172a;
    --sidebar-hover-bg: rgba(15, 23, 42, 0.05);
    --sidebar-active-bg: rgba(27, 110, 194, 0.12);
}

/* Brand mark for the ERP application */
.erp-brand-mark {
    width: 3rem;
    height: 3rem;
    border-radius: 1.1rem;
    font-family: var(--erp-font-display);
    font-size: 0.94rem;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
    box-shadow: 0 16px 30px rgba(29, 78, 216, 0.28);
}

/* Ensure printed numbers in RTL layout are readable (left-to-right) */
.erp-num {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-block;
}

/* New logo classes for sidebar/brand */
.erp-nav-logo-icon {
    width: 2.8rem;
    height: 2.8rem;
    object-fit: contain;
    border-radius: 0.6rem;
    box-shadow: 0 12px 28px rgba(29, 78, 216, 0.12);
    background: transparent;
    display: inline-block;
}

.erp-nav-logo-full {
    height: 2.4rem;
    object-fit: contain;
    display: inline-block;
}

.erp-nav-brand-text {
    font-family: var(--erp-font-display, system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif);
    font-size: 1rem;
    color: inherit;
    vertical-align: middle;
}

html[data-theme="dark"] {
    --app-bg: #0b1220;
    --app-fg: #e2e8f0;
    --muted: #cbd5e1;
    --card-bg: #0f172a;
    --card-border: #1e293b;
    --card-shadow: 0 12px 30px rgba(0,0,0,0.35);
    --link: #60a5fa;
    --primary: #3b82f6;
    --primary-border: #2563eb;
    --focus: #60a5fa;
    --sidebar-bg: #070b14;
    --sidebar-top-bg: rgba(255,255,255,0.05);
    --sidebar-border: rgba(255,255,255,0.08);
    --sidebar-link: #e2e8f0;
    --sidebar-link-hover: #ffffff;
    --sidebar-link-active: #ffffff;
    --sidebar-hover-bg: rgba(255,255,255,0.08);
    --sidebar-active-bg: rgba(255,255,255,0.12);
}

html[data-theme="ocean"] {
    --app-bg: #f5fbff;
    --app-fg: #062236;
    --muted: #446b86;
    --card-bg: #ffffff;
    --card-border: #d8e7f3;
    --card-shadow: 0 10px 24px rgba(6, 34, 54, 0.08);
    --link: #0077b6;
    --primary: #0096c7;
    --primary-border: #0077b6;
    --focus: #48cae4;
    --sidebar-bg: #062236;
    --sidebar-top-bg: rgba(255,255,255,0.06);
    --sidebar-border: rgba(255,255,255,0.10);
    --sidebar-link: #e6f6ff;
    --sidebar-link-hover: #ffffff;
    --sidebar-link-active: #ffffff;
    --sidebar-hover-bg: rgba(255,255,255,0.08);
    --sidebar-active-bg: rgba(255,255,255,0.12);
}

html, body {
    font-family: system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
    background: var(--app-bg);
    color: var(--app-fg);
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    border-radius: 14px;
}

.btn {
    border-radius: 10px;
}

.form-control, .form-select {
    border-radius: 10px;
}

a, .btn-link {
    color: var(--link);
}

.btn-primary {
    color: #fff;
    background-color: var(--primary);
    border-color: var(--primary-border);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.22rem var(--focus);
}

/* stronger, theme-appropriate focus ring for dark/ocean themes */
html[data-theme="dark"] .btn:focus,
html[data-theme="dark"] .btn:active:focus,
html[data-theme="dark"] .btn-link.nav-link:focus,
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-check-input:focus,
html[data-theme="ocean"] .btn:focus,
html[data-theme="ocean"] .btn:active:focus,
html[data-theme="ocean"] .btn-link.nav-link:focus,
html[data-theme="ocean"] .form-control:focus,
html[data-theme="ocean"] .form-check-input:focus {
  box-shadow: 0 0 0 0.18rem rgba(96,165,250,0.18);
}

.content {
    padding-top: 1.1rem;
}

.erp-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.erp-page .container,
.erp-page .container-fluid,
.erp-page .container-xxl {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.erp-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.15rem;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    background:
        radial-gradient(circle at top right, rgba(37, 140, 251, 0.12), transparent 28%),
        linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.86));
    box-shadow: var(--card-shadow);
}

html[data-theme="dark"] .erp-page-header {
    background:
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.18), transparent 30%),
        linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.90));
}

.erp-page-header h1 {
    margin: 0;
    font-size: clamp(1.4rem, 2vw, 1.95rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.erp-page-subtitle {
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.55;
    max-width: 60ch;
}

.erp-page-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.erp-page-actions > * {
    min-height: 40px;
}

.erp-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.95rem;
}

.erp-kpi-card {
    position: relative;
    border: 1px solid var(--card-border);
    border-radius: 18px;
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
    padding: 1rem 1.05rem;
    min-height: 108px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.55rem;
    overflow: hidden;
}

.erp-kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--bs-primary);
    opacity: 0.18;
}

.erp-kpi-label {
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.erp-kpi-value {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.05;
}

.erp-kpi-card.accent-success::before {
    background: #16a34a;
}

.erp-kpi-card.accent-info::before {
    background: #2563eb;
}

.erp-kpi-card.accent-warning::before {
    background: #d97706;
}

.erp-kpi-card.accent-danger::before {
    background: #dc2626;
}

@media (max-width: 767px) {
    .erp-page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .erp-page-actions {
        justify-content: flex-start;
    }
}

.erp-surface {
    border: 1px solid var(--card-border);
    border-radius: 18px;
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
}

.erp-surface > .card-header,
.erp-surface-header {
    padding: 1rem 1.15rem 0.85rem;
    border-bottom: 1px solid rgba(100, 116, 139, 0.14);
    background: transparent;
}

.erp-surface > .card-body,
.erp-surface-body {
    padding: 1.1rem 1.15rem 1.15rem;
}

.erp-surface-tight > .card-body,
.erp-surface-tight .erp-surface-body {
    padding: 0.95rem 1rem 1rem;
}

.erp-section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.erp-section-subtitle {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.erp-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.erp-toolbar .form-control,
.erp-toolbar .form-select {
    max-width: 360px;
}

.erp-feedback-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.erp-alert {
    border-radius: 14px;
    margin: 0;
}

.erp-loading {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--muted);
    min-height: 72px;
}

.searchable-select {
    position: relative;
}

.searchable-select-menu {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 0.38rem);
    z-index: 40;
    display: flex;
    flex-direction: column;
    max-height: 18rem;
    overflow-y: auto;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.16);
}

.searchable-select-option {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.82rem 0.95rem;
    border: 0;
    background: transparent;
    text-align: start;
}

.searchable-select-option.active,
.searchable-select-option:hover {
    background: rgba(37, 99, 235, 0.08);
}

.searchable-select-option-copy {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.searchable-select-option-label {
    font-weight: 700;
    color: var(--text);
}

.searchable-select-option-description {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.45;
}

.searchable-select-option-meta {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.84rem;
}

.searchable-select-state {
    padding: 0.95rem 1rem;
    color: var(--muted);
}

.erp-empty-state {
    border: 1px dashed rgba(100, 116, 139, 0.32);
    border-radius: 16px;
    padding: 1.1rem;
    text-align: center;
    color: var(--muted);
    background: rgba(148, 163, 184, 0.06);
}

.erp-table-wrap {
    border: 1px solid rgba(100, 116, 139, 0.14);
    border-radius: 16px;
    overflow: hidden;
    background: var(--card-bg);
}

.erp-table {
    margin-bottom: 0;
    vertical-align: middle;
}

.erp-table thead th {
    border-bottom-width: 1px;
    background: rgba(148, 163, 184, 0.10);
    color: var(--muted);
    font-size: 0.77rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

html[dir="rtl"] .erp-table thead th {
    letter-spacing: 0;
}

.erp-table tbody td {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.erp-table tbody tr:last-child td {
    border-bottom: 0;
}

.erp-table .text-wrap {
    white-space: normal !important;
}

.erp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}

.erp-badge-success {
    color: #166534;
    background: rgba(34, 197, 94, 0.16);
    border-color: rgba(34, 197, 94, 0.24);
}

.erp-badge-danger {
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.22);
}

.erp-badge-warning {
    color: #b45309;
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.22);
}

.erp-badge-info {
    color: #1d4ed8;
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.2);
}

.erp-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 0.32rem;
}

.erp-value {
    font-size: 1rem;
    font-weight: 600;
}

.erp-form-section {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.erp-form-section .validation-message {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.82rem;
}

.erp-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.9rem;
}

.erp-modal .modal-content {
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.20);
    overflow: hidden;
}

.erp-modal .modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(100, 116, 139, 0.14);
}

.erp-modal .modal-body {
    padding: 1.1rem 1.25rem 1.25rem;
}

.erp-modal .modal-footer {
    padding: 0.9rem 1.25rem 1.15rem;
    border-top: 1px solid rgba(100, 116, 139, 0.14);
}

.erp-page .table-responsive {
    scrollbar-width: thin;
}

.erp-page .btn-sm {
    min-height: 36px;
}

.erp-page .btn-lg {
    min-height: 52px;
}

.erp-page .form-text {
    color: var(--muted);
}

.pos-page .btn {
    min-height: 44px;
}

.pos-page .form-control,
.pos-page .form-select {
    min-height: 44px;
    font-size: 1.02rem;
}

.pos-page .table {
    font-size: 0.95rem;
}

.erp-num {
    display: inline-block;
    direction: ltr;
    unicode-bidi: isolate;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.return-kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.return-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.return-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--card-border);
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.10);
    color: var(--app-fg);
}

.return-chip code {
    font-size: 0.82rem;
}

.return-inline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin-top: 0.4rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.return-inline-meta strong {
    color: var(--app-fg);
}

.return-action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.return-total-card {
    min-width: min(100%, 220px);
    padding: 0.95rem 1rem;
    border-radius: 16px;
    border: 1px solid rgba(100, 116, 139, 0.16);
    background: rgba(37, 140, 251, 0.08);
}

.return-total-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}

.auth-page .card {
    border-radius: 16px;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 8mm;
    }

    html,
    body,
    .page,
    .erp-app-shell,
    .erp-main,
    .content,
    .erp-main-content,
    .erp-page-host {
        background: #fff !important;
        color: #000 !important;
    }

    /* Force only the dedicated print templates to be visible during printing
       Hide all screen UI by default and expose print-only sheets (.invoice-print-sheet and .invoice-print-area)
       This avoids printing the modal details + print template duplicates on /invoices. */
    body * {
        visibility: hidden !important;
    }

    .invoice-print-sheet,
    .invoice-print-sheet *,
    .invoice-print-area,
    .invoice-print-area * {
        visibility: visible !important;
        color: #000 !important;
    }

    /* Ensure print sheets occupy the page without forcing absolute positioning
       Use static flow to avoid forcing page-sized boxes that cause extra pages */
    /* Ensure print root controls layout and avoid absolute full-viewport boxes that cause extra pages */
    .invoice-print-root,
    .invoice-print-sheet,
    .invoice-print-area {
        position: static !important;
        display: block !important;
        width: auto !important;
        max-width: 210mm !important;
        background: #fff !important;
        padding: 0 !important;
        overflow: visible !important;
        margin: 0 auto !important;
    }

    /* Hide common modal/screen elements even if not annotated */
    .invoice-screen-details,
    .invoice-modal-kicker,
    .invoice-detail-actions,
    .invoice-action-notes,
    .modal-header,
    .modal-backdrop,
    .btn,
    .d-print-none {
        display: none !important;
    }

    body::before,
    .erp-page-header::after,
    .erp-kpi-card::after {
        display: none !important;
        content: none !important;
    }

    .top-row,
    .navbar-toggler,
    .nav-scrollable,
    .sidebar,
    .erp-sidebar,
    .erp-topbar,
    .erp-nav-settings,
    .erp-page-hero-premium,
    .erp-premium-toolbar,
    .erp-kpi-grid,
    .erp-page-actions,
    .no-print,
    button,
    .btn {
        display: none !important;
    }

    .content,
    .erp-main-content,
    .erp-page-host {
        padding: 0 !important;
        margin: 0 !important;
    }

    .pos-page {
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #fff !important;
        color: #000 !important;
    }

    .purchase-page {
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #fff !important;
        color: #000 !important;
    }

    .pos-page > * {
        display: none !important;
    }

    .pos-page > .invoice-print-area {
        display: block !important;
    }

    .purchase-page > * {
        display: none !important;
    }

    .purchase-page > .invoice-print-area {
        display: block !important;
    }

    .invoice-print-area,
    .invoice-print-card {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        color: #000 !important;
    }

    .invoice-print-area,
    .invoice-print-area * {
        color: #000 !important;
        background: #fff !important;
        box-shadow: none !important;
        text-shadow: none !important;
        filter: none !important;
    }

    .invoice-print-area {
        font-size: 10px;
        line-height: 1.4;
    }

    .invoice-print-area[dir="rtl"] {
        text-align: right;
    }

    .invoice-print-title {
        margin: 0 0 0.55rem !important;
        font-size: 18px !important;
        font-weight: 700 !important;
        text-align: center;
    }

    .invoice-print-meta {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.25rem 1rem;
        margin-bottom: 0.7rem;
    }

    .invoice-print-meta-item {
        font-size: 10px;
    }

    .invoice-print-meta-item strong {
        font-weight: 700;
    }

    .invoice-print-meta-item-wide {
        grid-column: 1 / -1;
    }

    .invoice-print-area .text-muted,
    .invoice-print-area .text-info,
    .invoice-print-area .text-success,
    .invoice-print-area .text-warning,
    .invoice-print-area .erp-money {
        color: #000 !important;
    }

    .invoice-amount,
    td.amount,
    .totals-table td:last-child,
    .totals-table td:first-child {
        direction: ltr;
        unicode-bidi: isolate;
        font-variant-numeric: tabular-nums;
    }

    .invoice-remaining-due {
        color: #c62828 !important;
    }

    .invoice-print-table {
        width: 100% !important;
        border-collapse: collapse !important;
        table-layout: fixed;
        margin: 0 !important;
        font-size: 9.5px;
    }

    .invoice-print-area .table {
        margin-bottom: 0 !important;
    }

    .invoice-print-table th,
    .invoice-print-table td {
        color: #000 !important;
        border: 1px solid #d6d6d6 !important;
        padding: 4px 5px !important;
        vertical-align: top !important;
        white-space: normal !important;
        word-break: break-word;
    }

    .invoice-print-table th:first-child,
    .invoice-print-table td:first-child {
        width: 20%;
    }

    .invoice-print-table th:not(:first-child),
    .invoice-print-table td:not(:first-child) {
        width: 8%;
    }

    .invoice-print-table thead th,
    .invoice-print-table tfoot th {
        font-weight: 700 !important;
        background: #fff !important;
    }

    .invoice-print-table thead,
    .receipt-items-table thead {
        display: table-header-group;
    }

    .invoice-print-table,
    .invoice-print-table tr,
    .invoice-print-table thead,
    .invoice-print-table tfoot,
    .receipt-items-table,
    .receipt-items-table tr,
    .receipt-items-table thead,
    .receipt-items-table tbody,
    .receipt-qr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .official-invoice-shell {
        display: grid !important;
        gap: 10px !important;
    }

    .official-invoice-head {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding-bottom: 8px !important;
        border-bottom: 1px solid #cbd5e1 !important;
    }

    .official-invoice-title {
        margin: 2px 0 !important;
        text-align: right !important;
    }

    .official-invoice-eyebrow,
    .official-invoice-subtitle,
    .official-meta-item span,
    .official-party-row span,
    .official-invoice-badge span {
        color: #000 !important;
    }

    .official-invoice-badge,
    .official-meta-item,
    .official-party-card,
    .official-summary-card,
    .official-table-wrap,
    .official-total-row,
    .receipt-total-row-final {
        border-color: #cbd5e1 !important;
        background: #fff !important;
    }

    .official-invoice-badge {
        min-width: 140px !important;
        padding: 8px 10px !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 12px !important;
        text-align: center !important;
    }

    .official-invoice-meta,
    .official-party-grid,
    .official-summary-grid {
        display: grid !important;
        gap: 8px !important;
    }

    .official-invoice-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .official-party-grid,
    .official-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .official-meta-item,
    .official-party-card,
    .official-summary-card {
        border: 1px solid #cbd5e1 !important;
        border-radius: 12px !important;
        padding: 8px 10px !important;
    }

    .official-card-title {
        margin-bottom: 6px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
    }

    .official-party-row {
        display: flex !important;
        justify-content: space-between !important;
        gap: 8px !important;
        padding: 4px 0 !important;
        border-bottom: 1px dashed #d6d6d6 !important;
    }

    .official-party-row:last-child {
        border-bottom: 0 !important;
    }

    .official-party-row strong {
        text-align: left !important;
    }

    .official-invoice-table {
        table-layout: fixed !important;
        font-size: 9.5px !important;
    }

    .official-invoice-table .official-col-product {
        width: 32% !important;
    }

    .official-invoice-table .official-col-qty {
        width: 10% !important;
    }

    .official-invoice-table .official-col-price,
    .official-invoice-table .official-col-discount,
    .official-invoice-table .official-col-before-tax,
    .official-invoice-table .official-col-tax,
    .official-invoice-table .official-col-total {
        width: 11.6% !important;
    }

    .official-invoice-table tbody tr,
    .receipt-items-table tbody tr {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .purchase-invoice-shell,
    .purchase-party-grid,
    .purchase-summary-grid {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .purchase-print-table {
        table-layout: fixed !important;
        font-size: 9px !important;
    }

    .purchase-print-table .purchase-col-product {
        width: 27% !important;
    }

    .purchase-print-table .purchase-col-unit {
        width: 10% !important;
    }

    .purchase-print-table .purchase-col-qty {
        width: 9% !important;
    }

    .purchase-print-table .purchase-col-price,
    .purchase-print-table .purchase-col-discount,
    .purchase-print-table .purchase-col-before-vat,
    .purchase-print-table .purchase-col-vat {
        width: 11% !important;
    }

    .purchase-print-table .purchase-col-total {
        width: 13% !important;
    }

    /* Stronger purchase print contrast and layout improvements */
    .purchase-invoice-shell {
        color: #000 !important;
    }

    .purchase-invoice-shell .official-invoice-eyebrow {
        color: #111 !important;
        font-weight: 700 !important;
        letter-spacing: 0.04em;
    }

    .purchase-invoice-shell .invoice-print-title {
        font-size: 20pt !important;
        font-weight: 800 !important;
        text-align: center !important;
        color: #111 !important;
        margin-bottom: 0.2rem !important;
    }

    .purchase-invoice-shell .official-invoice-badge {
        border-color: #9ca3af !important;
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
    }

    .purchase-party-grid .official-card-title,
    .purchase-summary-grid .official-card-title {
        color: #111 !important;
        font-weight: 700 !important;
    }

    .purchase-invoice-shell .official-party-row {
        border-bottom: 1px dashed #d1d5db !important;
    }

    /* Make purchase table clear and readable on paper */
    .purchase-print-table th,
    .purchase-print-table td {
        border: 1px solid #9ca3af !important;
        padding: 6px 8px !important;
        color: #000 !important;
        font-size: 10pt !important;
        vertical-align: top !important;
        word-break: break-word !important;
    }

    .purchase-print-table thead th {
        background: #f8fafb !important;
        color: #0f172a !important;
        font-weight: 700 !important;
    }

    .purchase-print-table tbody tr:nth-child(even) td {
        background: #fff !important;
    }

    /* Totals summary stronger visual weight */
    .official-summary-card.official-summary-card-total,
    .official-summary-card {
        border-color: #9ca3af !important;
        background: #fff !important;
    }

    .official-summary-card .official-party-row strong,
    .official-party-card .official-party-row strong {
        color: #0b1220 !important;
        font-weight: 700 !important;
    }

    /* Ensure printable font sizes and avoid pale shadows */
    .purchase-invoice-shell,
    .purchase-invoice-shell * {
        text-shadow: none !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .official-total-row {
        margin-top: 4px !important;
        padding-top: 6px !important;
        border-top: 1px solid #cbd5e1 !important;
        font-size: 12px !important;
        font-weight: 700 !important;
    }

    .receipt-print-card {
        width: 100% !important;
        padding: 0 !important;
    }

    .receipt-sheet {
        width: 100% !important;
        max-width: 132mm !important;
        margin: 0 auto !important;
        padding: 0 !important;
    }

    .receipt-header {
        margin-bottom: 0.8rem !important;
        padding-bottom: 0.65rem !important;
        border-bottom: 1px dashed #9ca3af !important;
        text-align: center !important;
    }

    .receipt-business-name {
        font-size: 16px !important;
        font-weight: 700 !important;
    }

    .receipt-title {
        font-size: 13px !important;
        font-weight: 700 !important;
        margin-top: 0.35rem !important;
    }

    .receipt-subtitle,
    .receipt-branch-name,
    .receipt-thanks,
    .receipt-meta-row span,
    .receipt-total-row span {
        color: #000 !important;
    }

    .receipt-meta-grid,
    .receipt-summary {
        gap: 0.25rem !important;
    }

    .receipt-items-table {
        width: 100% !important;
        border-collapse: collapse !important;
        table-layout: fixed !important;
        margin: 0 !important;
        font-size: 10px !important;
    }

    .receipt-items-table th,
    .receipt-items-table td {
        color: #000 !important;
        border: 1px solid #d6d6d6 !important;
        padding: 4px 5px !important;
        background: #fff !important;
        vertical-align: top !important;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .receipt-items-table th:first-child,
    .receipt-items-table td:first-child {
        width: 46% !important;
    }

    .receipt-items-table th:not(:first-child),
    .receipt-items-table td:not(:first-child) {
        width: 18% !important;
    }

    .receipt-items-table tbody tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .receipt-summary {
        margin-top: 0.7rem !important;
        padding-top: 0.65rem !important;
        border-top: 1px dashed #9ca3af !important;
    }

    .receipt-total-row-final {
        margin-top: 0.35rem !important;
        padding-top: 0.5rem !important;
        border-top: 1px solid #9ca3af !important;
        font-size: 12px !important;
        font-weight: 700 !important;
    }

    .receipt-qr {
        margin-top: 0.75rem !important;
    }

    .receipt-qr svg {
        width: 112px !important;
        height: 112px !important;
    }
}

@media (max-width: 991.98px) {
    .erp-page-header {
        flex-direction: column;
    }

    .erp-page-actions {
        width: 100%;
        justify-content: stretch;
    }

    .erp-page-actions > .btn,
    .erp-page-actions > a {
        flex: 1 1 180px;
    }

    .return-action-group > .btn {
        flex: 1 1 160px;
    }
}

/* Premium ERP polish */

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 22%),
        radial-gradient(circle at top left, rgba(14, 165, 233, 0.08), transparent 24%),
        var(--app-bg);
}

.content > .container,
.content > .container-fluid,
.content > .container-xxl {
    max-width: 100%;
}

.card,
.modal-content,
.dropdown-menu {
    border-radius: 20px;
    border-color: rgba(148, 163, 184, 0.18);
    box-shadow: 0 18px 46px rgba(15, 23, 42, 0.08);
}

.card-header {
    border-bottom-color: rgba(148, 163, 184, 0.14);
    background: linear-gradient(180deg, rgba(148, 163, 184, 0.06), rgba(148, 163, 184, 0.02));
}

.btn {
    font-weight: 600;
    letter-spacing: 0.01em;
    padding-inline: 1rem;
    min-height: 42px;
    box-shadow: none;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
}

.btn-primary {
    background-image: linear-gradient(135deg, rgba(255,255,255,0.08), transparent), linear-gradient(135deg, var(--primary), var(--primary-border));
    border-color: transparent;
    box-shadow: 0 18px 34px rgba(37, 99, 235, 0.22);
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-dark {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(10px);
}

html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-success,
html[data-theme="dark"] .btn-outline-danger,
html[data-theme="dark"] .btn-outline-dark,
html[data-theme="ocean"] .btn-outline-primary,
html[data-theme="ocean"] .btn-outline-secondary,
html[data-theme="ocean"] .btn-outline-success,
html[data-theme="ocean"] .btn-outline-danger,
html[data-theme="ocean"] .btn-outline-dark {
    background: rgba(15, 23, 42, 0.22);
}

.form-control,
.form-select,
.input-group-text,
textarea.form-control {
    min-height: 44px;
    border-radius: 14px;
    border-color: rgba(148, 163, 184, 0.22);
    background-color: rgba(255, 255, 255, 0.88);
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.56);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] textarea.form-control,
html[data-theme="ocean"] .form-control,
html[data-theme="ocean"] .form-select,
html[data-theme="ocean"] .input-group-text,
html[data-theme="ocean"] textarea.form-control {
    background-color: rgba(15, 23, 42, 0.28);
}

.form-control[readonly],
.form-control:disabled,
.form-select:disabled {
    background: linear-gradient(180deg, rgba(148, 163, 184, 0.12), rgba(148, 163, 184, 0.06));
    opacity: 1;
}

.form-label {
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--app-fg);
}

.form-text,
.text-muted {
    color: var(--muted) !important;
}

.alert {
    border: 1px solid transparent;
    border-radius: 18px;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.05);
}

.alert-warning {
    border-color: rgba(245, 158, 11, 0.22);
}

.alert-danger {
    border-color: rgba(239, 68, 68, 0.2);
}

.alert-success {
    border-color: rgba(34, 197, 94, 0.18);
}

.table-responsive {
    border-radius: 18px;
}

.table {
    --bs-table-bg: transparent;
}

.table > :not(caption) > * > * {
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
    border-bottom-color: rgba(148, 163, 184, 0.14);
}

.table thead th {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--muted);
    background: rgba(148, 163, 184, 0.08);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

html[dir="rtl"] .table thead th {
    letter-spacing: 0;
}

.table-hover tbody tr:hover {
    --bs-table-accent-bg: rgba(37, 99, 235, 0.04);
}

.badge,
.text-bg-success,
.text-bg-secondary,
.text-bg-danger,
.text-bg-warning,
.text-bg-info {
    border-radius: 999px;
    padding: 0.45rem 0.7rem;
    font-weight: 700;
}

.erp-page-header {
    position: relative;
    overflow: hidden;
}

.erp-page-header::after {
    content: "";
    position: absolute;
    inset-inline-end: -3rem;
    top: -3rem;
    width: 12rem;
    height: 12rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.14), transparent 66%);
    pointer-events: none;
}

.erp-page-actions .btn,
.erp-page-actions a.btn {
    min-width: 132px;
}

.erp-kpi-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.88));
}

html[data-theme="dark"] .erp-kpi-card {
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.88));
}

.erp-kpi-card::after {
    content: "";
    position: absolute;
    inset-inline-end: -1.5rem;
    bottom: -2rem;
    width: 7rem;
    height: 7rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(148, 163, 184, 0.16), transparent 70%);
}

.erp-kpi-helper {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.erp-card-title,
.erp-list-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.erp-card-subtitle {
    margin-top: 0.22rem;
    color: var(--muted);
    font-size: 0.84rem;
}

.erp-section {
    border: 1px solid var(--card-border);
    border-radius: 20px;
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
}

.erp-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem 0.9rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.erp-section-body {
    padding: 1rem 1.15rem 1.15rem;
}

.erp-info-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.9rem;
}

.erp-info-item {
    padding: 0.9rem 1rem;
    border-radius: 16px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.erp-info-item strong {
    display: block;
    margin-top: 0.25rem;
    font-size: 1rem;
    color: var(--app-fg);
}

.erp-quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.erp-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.erp-check-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 16px;
    background: rgba(148, 163, 184, 0.05);
}

.erp-check-item .form-check {
    margin: 0;
}

.erp-inline-hint {
    margin-top: 0.45rem;
    font-size: 0.82rem;
    color: var(--muted);
}

.erp-empty-state strong {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--app-fg);
}

.erp-page .code-muted,
.erp-info-item code,
.erp-session-card code {
    font-size: 0.78rem;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.12);
    padding: 0.14rem 0.4rem;
}

.erp-admin-split {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr);
    gap: 1rem;
}

.erp-form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.erp-form-actions .btn {
    flex: 1 1 180px;
}

@media (max-width: 1199.98px) {
    .erp-admin-split {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .erp-page-actions .btn,
    .erp-page-actions a.btn,
    .erp-form-actions .btn {
        width: 100%;
    }

    .erp-section-header {
        flex-direction: column;
    }
}
