:root {
    --app-bg:#f5f7fb;
    --app-text:#182230;
    --app-muted:#667085;
    --app-border:#e7eaf0;
    --app-card:#ffffff;
    --app-primary:#2563eb;
}

* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body { background:var(--app-bg); color:var(--app-text); }
.app-container { padding:24px; }
.card { border:1px solid var(--app-border); border-radius:18px; box-shadow:0 8px 24px rgba(16,24,40,.06); }
.btn, .form-control, .form-select { border-radius:12px; }
.table > :not(caption) > * > * { vertical-align:middle; }
.badge-soft { background:#eef2ff; color:#3538cd; }
.stat-card { min-height:120px; }
.navbar-brand { letter-spacing:-.02em; }
.page-actions { display:flex; gap:.5rem; flex-wrap:wrap; justify-content:flex-end; }
.form-section-title { font-size:.9rem; font-weight:700; color:#344054; text-transform:uppercase; letter-spacing:.04em; margin-bottom:.75rem; }
.employee-avatar { width:42px; height:42px; border-radius:999px; object-fit:cover; background:#eef2ff; border:1px solid #dbe3ff; display:inline-flex; align-items:center; justify-content:center; font-weight:700; color:#3538cd; }
.employee-avatar-lg { width:118px; height:118px; border-radius:24px; object-fit:cover; background:#eef2ff; border:1px solid #dbe3ff; display:flex; align-items:center; justify-content:center; font-size:2rem; font-weight:700; color:#3538cd; }
.mobile-card-title { font-weight:700; }
.action-stack { display:flex; gap:.35rem; justify-content:flex-end; flex-wrap:wrap; }
.touch-target { min-height:44px; display:inline-flex; align-items:center; justify-content:center; }

@media (max-width: 991.98px) {
    .app-container { padding:16px; }
    .navbar .btn { width:100%; margin-top:.35rem; }
    .navbar .d-flex { align-items:stretch !important; width:100%; margin-top:.5rem; }
    .navbar-nav .nav-link { padding:.7rem 0; border-bottom:1px solid #f0f2f5; }
    .page-header { align-items:flex-start !important; gap:.75rem; flex-direction:column; }
    .page-actions { width:100%; justify-content:stretch; }
    .page-actions .btn { flex:1 1 auto; min-height:44px; }
}

@media (max-width: 767.98px) {
    body { font-size:15px; }
    h1, .h1 { font-size:1.55rem; }
    .h3 { font-size:1.3rem; }
    .card { border-radius:16px; }
    .card.p-4 { padding:1rem !important; }
    .btn { min-height:42px; }
    .table-responsive.mobile-card-table { overflow:visible; }
    table.mobile-card-table,
    table.mobile-card-table thead,
    table.mobile-card-table tbody,
    table.mobile-card-table th,
    table.mobile-card-table td,
    table.mobile-card-table tr { display:block; width:100%; }
    table.mobile-card-table thead { display:none; }
    table.mobile-card-table tr { background:#fff; border:1px solid var(--app-border); border-radius:16px; margin-bottom:.85rem; padding:.75rem; box-shadow:0 4px 14px rgba(16,24,40,.04); }
    table.mobile-card-table td { border:0 !important; padding:.45rem 0 !important; display:flex; justify-content:space-between; gap:1rem; align-items:flex-start; }
    table.mobile-card-table td::before { content:attr(data-label); font-weight:700; color:#475467; flex:0 0 42%; }
    table.mobile-card-table td.mobile-full { display:block; }
    table.mobile-card-table td.mobile-full::before { display:block; margin-bottom:.25rem; }
    table.mobile-card-table td.no-label::before { content:''; display:none; }
    .action-stack { justify-content:stretch; }
    .action-stack .btn { flex:1 1 100%; }
}

.mini-stat { border:1px solid var(--app-border); border-radius:16px; padding:1rem; background:#fff; }
.mini-stat span { display:block; color:var(--app-muted); font-size:.85rem; }
.mini-stat strong { display:block; font-size:1.35rem; margin-top:.2rem; }

@media print {
    .navbar, .no-print, .page-actions { display:none !important; }
    body { background:#fff; }
    .app-container { padding:0; }
    .card { box-shadow:none; border:1px solid #ddd; }
}

/* Consistent transaction status badges */
.badge.status-badge {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:.25rem;
    border-radius:999px;
    padding:.42rem .65rem;
    font-size:.72rem;
    font-weight:800;
    line-height:1;
    letter-spacing:.035em;
    border:1px solid transparent;
    white-space:nowrap;
    text-transform:uppercase;
}
.status-success { background:#dcfce7 !important; color:#166534 !important; border-color:#bbf7d0 !important; }
.status-warning { background:#fef3c7 !important; color:#92400e !important; border-color:#fde68a !important; }
.status-danger  { background:#fee2e2 !important; color:#991b1b !important; border-color:#fecaca !important; }
.status-info    { background:#dbeafe !important; color:#1e40af !important; border-color:#bfdbfe !important; }
.status-dark    { background:#e5e7eb !important; color:#111827 !important; border-color:#d1d5db !important; }
.status-neutral { background:#f8fafc !important; color:#475467 !important; border-color:#e4e7ec !important; }
.status-badge-lg { font-size:.86rem; padding:.55rem .8rem; }


/* V1.10.3: stronger status badge colours */
.badge.status-badge.status-success { background:#dcfce7 !important; color:#166534 !important; border-color:#bbf7d0 !important; }
.badge.status-badge.status-warning { background:#fef3c7 !important; color:#92400e !important; border-color:#fde68a !important; }
.badge.status-badge.status-danger  { background:#fee2e2 !important; color:#991b1b !important; border-color:#fecaca !important; }
.badge.status-badge.status-info    { background:#dbeafe !important; color:#1e40af !important; border-color:#bfdbfe !important; }
.badge.status-badge.status-dark    { background:#e5e7eb !important; color:#111827 !important; border-color:#d1d5db !important; }
.badge.status-badge.status-neutral { background:#f8fafc !important; color:#475467 !important; border-color:#e4e7ec !important; }

/* V1.22: dashboard and report grouping polish */
.dashboard-stat-card,
.workflow-card,
.report-card {
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.dashboard-stat-card:hover,
.workflow-card:hover,
.report-card:hover {
    transform: translateY(-1px);
    border-color:#c7d7fe;
    box-shadow:0 12px 30px rgba(16,24,40,.09);
}
.workflow-link-grid {
    display:flex;
    flex-wrap:wrap;
    gap:.5rem;
}
.workflow-link-grid .btn {
    flex:1 1 180px;
    text-align:left;
    justify-content:flex-start;
}
.report-section {
    scroll-margin-top:90px;
}
.report-card {
    display:flex;
    flex-direction:column;
}
@media (max-width: 767.98px) {
    .workflow-link-grid .btn {
        flex:1 1 100%;
        text-align:center;
    }
}

/* V1.23 Global Smart Search */
.app-global-search {
    position: relative;
    min-width: 300px;
    max-width: 430px;
    width: 30vw;
    margin-right: 0.75rem;
}
.app-global-search .form-control {
    border-radius: 999px;
    padding-left: 1rem;
    padding-right: 1rem;
    background: #f8fafc;
}
.global-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 1060;
    display: none;
    max-height: 430px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #d8e1ea;
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .14);
    padding: .45rem;
}
.global-search-results.show { display: block; }
.global-search-result {
    display: block;
    text-decoration: none;
    color: #1f2933;
    padding: .65rem .75rem;
    border-radius: 12px;
}
.global-search-result:hover,
.global-search-result.active {
    background: #eef5ff;
    color: #163f73;
}
.global-search-title {
    display: block;
    font-weight: 700;
    line-height: 1.15;
}
.global-search-meta {
    display: inline-block;
    margin-top: .2rem;
    font-size: .75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.global-search-desc {
    display: block;
    margin-top: .12rem;
    font-size: .82rem;
    color: #64748b;
}
.global-search-empty {
    padding: .75rem;
    font-size: .9rem;
    color: #64748b;
}

/* V1.24 Reusable Item Picker */
.item-picker {
    position: relative;
    min-width: 300px;
}
.item-picker-input-group {
    display: flex;
    gap: .35rem;
}
.item-picker-input {
    min-width: 220px;
}
.item-picker-clear {
    white-space: nowrap;
}
.item-picker-selected {
    min-height: 1.15rem;
    margin-top: .2rem;
    font-size: .78rem;
}
.item-picker-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    display: none;
    z-index: 1070;
    max-height: 340px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #d8e1ea;
    border-radius: 14px;
    box-shadow: 0 18px 38px rgba(15, 23, 42, .14);
    padding: .35rem;
}
.item-picker-results.show { display: block; }
.item-picker-result {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: #1f2933;
    padding: .62rem .7rem;
    border-radius: 11px;
}
.item-picker-result:hover,
.item-picker-result:focus {
    background: #eef5ff;
    color: #163f73;
    outline: none;
}
.item-picker-result-main,
.item-picker-result-sub,
.item-picker-result-desc {
    display: block;
}
.item-picker-result-main {
    font-size: .92rem;
    line-height: 1.2;
}
.item-picker-result-sub {
    margin-top: .2rem;
    color: #475569;
    font-size: .8rem;
}
.item-picker-result-desc {
    margin-top: .15rem;
    color: #64748b;
    font-size: .78rem;
    line-height: 1.25;
}
.item-picker-empty {
    padding: .7rem;
    color: #64748b;
    font-size: .88rem;
}

@media (max-width: 1199.98px) {
    .app-global-search {
        width: 100%;
        max-width: none;
        margin: .75rem 0;
    }
    .global-search-results {
        position: static;
        margin-top: .4rem;
        max-height: 300px;
    }
}

@media (max-width: 767.98px) {
    .item-picker {
        min-width: 100%;
    }
    .item-picker-results {
        position: static;
        margin-top: .35rem;
        max-height: 260px;
    }
}

/* V1.32 Item Images / Fitment Photos */
.item-thumb-md,
.item-picker-thumb,
.stock-transfer-thumb,
.pos-search-thumb,
.pos-cart-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: .75rem;
    border: 1px solid #d8e1ea;
    background: #f8fafc;
    flex: 0 0 auto;
}
.item-thumb-md {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    font-size: .68rem;
    text-align: center;
    color: #64748b;
}
.item-thumb-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .25rem;
    background: #f1f5f9;
    color: #64748b;
    font-size: .68rem;
    line-height: 1.05;
    text-align: center;
}
.item-picker-result.item-picker-result-with-image {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: .7rem;
    align-items: center;
}
.item-picker-result-body {
    min-width: 0;
}
.item-picker-result-fitment {
    display: block;
    margin-top: .15rem;
    color: #0d6efd;
    font-size: .78rem;
}
.item-image-edit-card {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1rem;
    height: 100%;
    background: #fbfdff;
}
.item-image-preview {
    max-width: 100%;
    width: 220px;
    height: 150px;
    object-fit: cover;
    border-radius: 1rem;
    border: 1px solid #d8e1ea;
    background: #f8fafc;
}
.item-image-placeholder,
.item-image-large-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
    background: #f8fafc;
    color: #64748b;
    min-height: 150px;
    text-align: center;
    padding: 1rem;
}
.item-image-large {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: contain;
    border-radius: 1rem;
    border: 1px solid #d8e1ea;
    background: #f8fafc;
}
.stock-on-hand-item-cell {
    display: flex;
    gap: .7rem;
    align-items: center;
}
@media (max-width: 767.98px) {
    .item-picker-result.item-picker-result-with-image {
        grid-template-columns: 46px minmax(0, 1fr);
    }
    .item-picker-thumb,
    .stock-transfer-thumb,
    .pos-search-thumb,
    .pos-cart-thumb {
        width: 46px;
        height: 46px;
    }
}
