:root {
    --erp-sidebar-width: 280px;
    --erp-sidebar-collapsed: 72px;
    --erp-header-height: 62px;
    --erp-sidebar-bg: #0f172a;
    --erp-sidebar-bg-2: #111c34;
    --erp-sidebar-color: #cbd5e1;
    --erp-sidebar-active: #2563eb;
    --erp-accent: #2563eb;
    --erp-content-bg: #f1f5f9;
    --erp-dropdown-z: 1045;
    --erp-modal-z: 1060;
    --erp-toast-z: 1090;
    --erp-toast-min-width: 450px;
    --erp-toast-success: #16a34a;
    --erp-toast-error: #dc2626;
    --erp-toast-warning: #d97706;
    --erp-toast-info: #2563eb;
}

[x-cloak] { display: none !important; }

body { background: var(--erp-content-bg); }

/* ---------- Table / card overflow (action menus) ---------- */
.erp-card,
.erp-content .card {
    overflow: visible;
}

.erp-card > .table-responsive,
.erp-content .table-responsive,
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > .table {
    margin-bottom: 0;
}

.table td .dropdown,
.table th .dropdown,
.table-responsive .dropdown,
.erp-row-action-menu {
    position: relative;
}

.erp-row-action-menu .dropdown-menu,
.table .dropdown-menu,
.erp-card .dropdown-menu {
    z-index: var(--erp-dropdown-z);
}

.table thead th {
    position: relative;
    z-index: 2;
}

.modal {
    z-index: var(--erp-modal-z);
}

.modal-backdrop {
    z-index: calc(var(--erp-modal-z) - 5);
}
.btn-primary{ padding: 5px 10px !important; font-size: 12px; font-weight: 500; }
/* ---------- Layout shell ---------- */
.erp-wrapper { display: flex; min-height: 100vh; }
tbody, td, tfoot, th, thead, tr, p { font-size: 14px; }
.h4, h4 { font-size: calc(0.775rem + .3vw); }
.erp-sidebar {
    width: var(--erp-sidebar-width);
    background: linear-gradient(180deg, var(--erp-sidebar-bg) 0%, var(--erp-sidebar-bg-2) 100%);
    color: var(--erp-sidebar-color);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width .2s ease, transform .2s ease;
    overflow: hidden;
}

.erp-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--erp-sidebar-width);
    transition: margin-left .2s ease;
}

.sidebar-collapsed .erp-sidebar { width: var(--erp-sidebar-collapsed); }
.sidebar-collapsed .erp-main { margin-left: var(--erp-sidebar-collapsed); }
.sidebar-collapsed .erp-sidebar .erp-menu-text,
.sidebar-collapsed .erp-sidebar .erp-menu-arrow,
.sidebar-collapsed .erp-sidebar .erp-menu-header,
.sidebar-collapsed .erp-sidebar .erp-brand-text { display: none; }
.sidebar-collapsed .erp-sidebar .erp-submenu { display: none !important; }

/* ---------- Sidebar brand ---------- */
.erp-brand {
    height: var(--erp-header-height);
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1rem;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.erp-brand i { font-size: 1.5rem; color: var(--erp-accent); }
.erp-brand-logo-img { max-height: 36px; max-width: 140px; object-fit: contain; }
.sidebar-collapsed .erp-sidebar .erp-brand-logo-img { max-width: 36px; }
.erp-brand-text { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }

/* ---------- Sidebar nav ---------- */
.erp-nav {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    padding: .5rem 0;
    scrollbar-gutter: stable;
}
.erp-nav::-webkit-scrollbar { width: 10px; }
.erp-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

.erp-menu-header {
    text-transform: uppercase;
    font-size: .68rem;
    letter-spacing: .08em;
    color: #64748b;
    padding: 1rem 1.25rem .35rem;
    font-weight: 600;
}

.erp-nav-item { list-style: none; }
.erp-nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .3rem 1rem;
    color: var(--erp-sidebar-color);
    text-decoration: none;
    border-left: 3px solid transparent;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.erp-nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.erp-nav-link i.erp-menu-icon { font-size: 14px; width: 1.25rem; text-align: center; }
.erp-nav-link.active {
    background: rgba(37,99,235,.15);
    color: #fff;
    border-left-color: var(--erp-sidebar-active);
}
.erp-menu-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}
.erp-menu-arrow {
    flex-shrink: 0;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    opacity: 1;
    visibility: visible;
    transition: transform .2s ease;
    font-size: .8rem;
}
.erp-nav-link.erp-nav-link--open .erp-menu-arrow,
.erp-nav-link[aria-expanded="true"] .erp-menu-arrow { transform: rotate(90deg); }

/* ---------- Submenus (multi-level) ---------- */
.erp-submenu { list-style: none; padding-left: 0; background: rgba(0,0,0,.18); }
.erp-submenu .erp-nav-link { padding-left: 2.0rem; font-size: .9rem; }
.erp-submenu .erp-submenu .erp-nav-link { padding-left: 3.9rem; }

/* ---------- Header ---------- */
.erp-header {
    height: var(--erp-header-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.erp-header .erp-search { max-width: 420px; flex: 1; position: relative; }
.erp-header .erp-search-results {
    position: absolute; top: 110%; left: 0; right: 0;
    background: #fff; border: 1px solid #e2e8f0; border-radius: .5rem;
    box-shadow: 0 12px 28px rgba(2,6,23,.12); z-index: 1050; max-height: 420px; overflow-y: auto;
}

/* ---------- Unsaved changes guard modal ---------- */
#erpUnsavedModal.show {
    background: rgba(2, 6, 23, .55);
}
body.erp-guard-open {
    overflow: hidden;
}

/* ---------- Breadcrumb ---------- */
.erp-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    background: transparent;
}
.erp-breadcrumb .erp-breadcrumb-home {
    display: inline-flex;
    align-items: center;
    color: var(--erp-accent);
    text-decoration: none;
    font-size: 1.05rem;
    line-height: 1;
}
.erp-breadcrumb .erp-breadcrumb-home:hover { color: #1d4ed8; }
.erp-breadcrumb .breadcrumb-separator { color: #94a3b8; line-height: 1; }
.erp-breadcrumb .erp-breadcrumb-link,
.erp-breadcrumb .erp-breadcrumb-text {
    color: #64748b;
    font-size: .95rem;
}
.erp-breadcrumb .erp-breadcrumb-link {
    text-decoration: none;
}
.erp-breadcrumb .erp-breadcrumb-link:hover { color: var(--erp-accent); }
.erp-breadcrumb .page-title {
    font-weight: 600;
    color: #0f172a;
    font-size: 1rem;
}

/* ---------- Content ---------- */
.erp-content { flex: 1; }
.erp-card { background: #fff; border: 1px solid #e2e8f0; border-radius: .75rem; }

/* ---------- Badges ---------- */
.erp-badge i { font-size: .5rem; vertical-align: middle; margin-right: .15rem; }

/* Standard ERP status badge palette (see App\Support\ErpStatusBadge) */
.erp-status-active { background-color: #198754 !important; color: #fff !important; }
.erp-status-inactive { background-color: #6c757d !important; color: #fff !important; }
.erp-status-locked { background-color: #ffc107 !important; color: #000 !important; }
.erp-status-pending { background-color: #fd7e14 !important; color: #fff !important; }
.erp-status-draft { background-color: #0d6efd !important; color: #fff !important; }
.erp-status-cancelled { background-color: #dc3545 !important; color: #fff !important; }

/* ---------- Employee summary ---------- */
.erp-avatar-placeholder {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: .04em;
}
.erp-info-list dt {
    font-weight: 500;
    color: #64748b;
    padding-bottom: .6rem;
    font-size: .9rem;
}
.erp-info-list dd {
    font-weight: 500;
    color: #0f172a;
    padding-bottom: .6rem;
    margin-bottom: 0;
}
.erp-info-list dt:last-of-type,
.erp-info-list dd:last-of-type { padding-bottom: 0; }

/* ---------- Notifications (Filament-inspired) ---------- */
.erp-toast-stack {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: var(--erp-toast-z);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    min-width: var(--erp-toast-min-width);
    max-width: min(var(--erp-toast-min-width), calc(100vw - 2rem));
    pointer-events: none;
}

.erp-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
    min-width: var(--erp-toast-min-width);
    max-width: min(var(--erp-toast-min-width), calc(100vw - 2rem));
    padding: 1rem 1rem 1rem 1.125rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow:
        0 10px 15px -3px rgba(15, 23, 42, 0.12),
        0 4px 6px -4px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.erp-toast--success { border-left: 4px solid var(--erp-toast-success); }
.erp-toast--error   { border-left: 4px solid var(--erp-toast-error); }
.erp-toast--warning { border-left: 4px solid var(--erp-toast-warning); }
.erp-toast--info    { border-left: 4px solid var(--erp-toast-info); }

.erp-toast__icon {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    margin-top: 0.05rem;
}

.erp-toast--success .erp-toast__icon { color: var(--erp-toast-success); }
.erp-toast--error   .erp-toast__icon { color: var(--erp-toast-error); }
.erp-toast--warning .erp-toast__icon { color: var(--erp-toast-warning); }
.erp-toast--info    .erp-toast__icon { color: var(--erp-toast-info); }

.erp-toast__content {
    flex: 1 1 auto;
    min-width: 0;
}

.erp-toast__title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    color: #111827;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.erp-toast__body {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #6b7280;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.erp-toast__close {
    flex-shrink: 0;
    border: 0;
    background: transparent;
    color: #9ca3af;
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: color .15s ease, background-color .15s ease;
}

.erp-toast__close:hover {
    color: #374151;
    background: #f3f4f6;
}

/* Toast enter/leave transitions */
.erp-toast-enter { transition: all .2s ease-out; }
.erp-toast-enter-start { opacity: 0; transform: translateX(1rem); }
.erp-toast-enter-end { opacity: 1; transform: translateX(0); }
.erp-toast-leave { transition: all .15s ease-in; }
.erp-toast-leave-start { opacity: 1; transform: translateX(0); }
.erp-toast-leave-end { opacity: 0; transform: translateX(1rem); }

/* Inline session flash (page-level, same visual language) */
.erp-flash {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.125rem;
    margin-bottom: 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.erp-flash--success { border-left: 4px solid var(--erp-toast-success); }
.erp-flash--error   { border-left: 4px solid var(--erp-toast-error); }
.erp-flash--warning { border-left: 4px solid var(--erp-toast-warning); }
.erp-flash--info    { border-left: 4px solid var(--erp-toast-info); }

.erp-flash__icon {
    flex-shrink: 0;
    font-size: 1.125rem;
    line-height: 1.4;
}

.erp-flash--success .erp-flash__icon { color: var(--erp-toast-success); }
.erp-flash--error   .erp-flash__icon { color: var(--erp-toast-error); }
.erp-flash--warning .erp-flash__icon { color: var(--erp-toast-warning); }
.erp-flash--info    .erp-flash__icon { color: var(--erp-toast-info); }

.erp-flash__content {
    flex: 1 1 auto;
    min-width: 0;
}

.erp-flash__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}

.erp-flash__body {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #6b7280;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.erp-flash__list {
    padding-left: 1.1rem;
}

.erp-flash__close {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

@media (max-width: 575.98px) {
    .erp-toast-stack,
    .erp-toast {
        min-width: 0;
        width: calc(100vw - 2rem);
        max-width: calc(100vw - 2rem);
    }
}

/* ---------- Backdrop (mobile) ---------- */
.erp-backdrop { display: none; }

/* ---------- Auth pages ---------- */
.erp-auth-body {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    padding: 1.5rem;
}
.erp-auth-wrapper { width: 100%; max-width: 420px; }
.erp-auth-card { background: #fff; border-radius: 1rem; padding: 2.25rem; }
.erp-auth-logo {
    width: 64px; height: 64px; border-radius: 1rem;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.8rem;
}

/* ---------- Searchable product select ---------- */
.erp-product-select-menu {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 280px;
    overflow-y: auto;
}

.erp-product-select-option:hover,
.erp-product-select-option:focus {
    background: #eff6ff !important;
    outline: none;
}

/* ---------- Standard pagination footer ---------- */
.erp-pagination-footer {
    background: #fff;
    width: 100%;
}

.erp-pagination-footer.card-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.erp-pagination-nav .pagination {
    gap: 0.15rem;
}

.erp-pagination-nav .page-link {
    min-width: 2.25rem;
    text-align: center;
    border-radius: 0.375rem;
    color: #334155;
    border-color: #e2e8f0;
    padding: 0.35rem 0.65rem;
    line-height: 1.25;
}

.erp-pagination-nav .page-item.active .page-link {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.erp-pagination-nav .page-item.disabled .page-link {
    color: #94a3b8;
    background-color: #f8fafc;
}

.erp-pagination-nav .page-link:hover:not(.active) {
    background-color: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.erp-card > .erp-pagination-footer,
.card > .erp-pagination-footer,
.table-responsive + .erp-pagination-footer {
    margin-top: 0;
}

@media (max-width: 767.98px) {
    .erp-pagination-footer {
        text-align: center;
    }

    .erp-pagination-summary {
        order: 2;
    }

    .erp-pagination-links {
        order: 1;
    }
}

@media (min-width: 768px) {
    .erp-pagination-footer {
        flex-direction: row !important;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .erp-sidebar { transform: translateX(-100%); }
    .erp-main { margin-left: 0; }
    .sidebar-mobile-open .erp-sidebar { transform: translateX(0); }
    .sidebar-mobile-open .erp-backdrop {
        display: block; position: fixed; inset: 0;
        background: rgba(2,6,23,.5); z-index: 1035;
    }
}

/* ---------- Branding asset upload (Company Settings) ---------- */
.erp-branding-box {
    position: relative;
    width: 100%;
    max-width: 200px;
    margin-left: auto;
    margin-right: auto;
    aspect-ratio: 1;
    border: 2px dashed #cbd5e1;
    border-radius: 0.75rem;
    background: #f8fafc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.erp-branding-box:hover,
.erp-branding-box:focus-visible {
    border-color: #2563eb;
    background: #eff6ff;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

.erp-branding-box--dragging {
    border-color: #2563eb;
    background: #dbeafe;
    box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.2);
}

.erp-branding-box__placeholder {
    width: 100%;
}

.erp-branding-box__icon {
    font-size: 1.75rem;
    color: #64748b;
}

.erp-branding-box__image {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.erp-branding-box__img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0.35rem;
}

.erp-branding-box__delete {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    z-index: 2;
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.erp-branding-box__delete:hover {
    background: #b91c1c;
}

.erp-branding-box__delete:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(220, 38, 38, 0.4);
}

.erp-branding-upload__status-text {
    color: #dc2626;
    font-weight: 600;
    animation: erp-branding-pulse 1.5s ease-in-out infinite;
}

.erp-branding-upload__status--active {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.erp-branding-upload__dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #dc2626;
    flex-shrink: 0;
    animation: erp-branding-pulse 1.5s ease-in-out infinite;
}

@keyframes erp-branding-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@media (max-width: 575.98px) {
    .erp-branding-box {
        max-width: 180px;
    }
}

.party-contacts-toolbar-search {
    max-width: 100%;
}

@media (min-width: 576px) {
    .party-contacts-toolbar-search {
        max-width: 260px;
    }
}

.nav-tabs .nav-link.party-tab-has-errors {
    color: #dc2626;
}

.nav-tabs .nav-link.party-tab-has-errors.active {
    color: #dc2626;
    border-bottom-color: #dc2626;
}
