/* ── Mobile bottom navigation ── */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: space-around;
    align-items: center;
    min-height: 62px;
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom, 0px));
    z-index: 1030;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.08);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #6c757d;
    text-decoration: none;
    font-size: 0.7rem;
    justify-content: center;
    border-radius: 0.65rem;
    padding: 4px 6px;
    min-width: 0;
    min-height: 48px;
    flex: 1 1 0;
    transition: color .15s ease, background-color .15s ease;
}

.mobile-nav-item i {
    font-size: 1.3rem;
    margin-bottom: 1px;
}

.mobile-nav-item.active {
    color: #0d6efd;
    background: #eef5ff;
    font-weight: 600;
}

/* ── Responsive tables on mobile ── */
@media (max-width: 991.98px) {
    body {
        background: #f7f9fc;
    }

    .navbar {
        position: sticky;
        top: 0;
        z-index: 1025;
        margin-bottom: .75rem !important;
        box-shadow: 0 2px 10px rgba(15, 23, 42, .12);
    }

    .navbar-brand {
        font-size: 1.05rem;
    }

    .navbar-collapse {
        padding-top: .5rem;
        padding-bottom: .5rem;
    }

    .navbar-collapse .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        gap: .45rem;
        padding-left: .75rem;
        border-radius: .5rem;
    }

    main.container-fluid {
        padding-left: .75rem;
        padding-right: .75rem;
        padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .card {
        border-radius: .8rem;
        box-shadow: 0 .15rem .45rem rgba(15, 23, 42, .045);
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 767.98px) {
    .table-responsive-stack td,
    .table-responsive-stack th {
        display: block;
    }

    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }

    .btn {
        white-space: nowrap;
    }

    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px;
    }

    textarea.form-control {
        min-height: 6rem;
    }

    .page-heading-actions,
    .mobile-full-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .page-heading-actions > .btn,
    .page-heading-actions > form,
    .mobile-full-actions > .btn,
    .mobile-full-actions > form {
        flex: 1 1 auto;
    }

    .page-heading-actions > form .btn,
    .mobile-full-actions > form .btn {
        width: 100%;
    }

    .mobile-record-card .card-body {
        padding: .85rem;
    }

    .mobile-record-card .record-meta {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .45rem .75rem;
    }

    .mobile-record-card .record-meta small {
        display: block;
        color: #6c757d;
        margin-bottom: .05rem;
    }

    .mobile-record-card .grid-column-full {
        grid-column: 1 / -1;
    }

    .purchase-edit-table thead {
        display: none;
    }

    .purchase-edit-table,
    .purchase-edit-table tbody,
    .purchase-edit-table tr,
    .purchase-edit-table td {
        display: block;
        width: 100%;
    }

    .purchase-edit-table tbody {
        padding: .75rem;
    }

    .purchase-edit-table tr {
        position: relative;
        margin-bottom: .75rem;
        padding: .75rem;
        border: 1px solid #dee2e6;
        border-radius: .75rem;
        background: #fff;
    }

    .purchase-edit-table tr:last-child {
        margin-bottom: 0;
    }

    .purchase-edit-table td {
        border: 0;
        padding: .35rem 0;
    }

    .purchase-edit-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: .2rem;
        color: #6c757d;
        font-size: .78rem;
        font-weight: 600;
    }

    .purchase-edit-table .row-number {
        width: 2rem;
        height: 2rem;
        display: grid;
        place-items: center;
        padding: 0;
        border-radius: 50%;
        background: #eef5ff;
        color: #0d6efd;
        font-weight: 700;
    }

    .purchase-edit-table td:last-child {
        position: absolute;
        top: .6rem;
        right: .6rem;
        width: auto;
        padding: 0;
    }
}

/* ── Touch-friendly buttons ── */
@media (max-width: 767.98px) {
    form .btn,
    .card .btn {
        min-height: 40px;
    }
}

/* ── Card hover ── */
.card-hover:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s ease;
}

/* ── Inventory views ── */
.inventory-location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.65rem;
}

.inventory-location-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem;
    color: #334155;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.75rem;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.inventory-location-card:hover {
    color: #0d6efd;
    border-color: #86b7fe;
    box-shadow: 0 0.25rem 0.8rem rgba(13, 110, 253, .09);
    transform: translateY(-1px);
}

.inventory-location-card.active {
    color: #0a58ca;
    background: #eef5ff;
    border-color: #0d6efd;
    box-shadow: inset 0 0 0 1px #0d6efd;
}

.inventory-location-card small {
    display: block;
    color: #6c757d;
    margin-top: 0.1rem;
}

.inventory-location-icon {
    display: grid;
    place-items: center;
    width: 2.15rem;
    height: 2.15rem;
    flex: 0 0 auto;
    border-radius: 0.65rem;
    background: rgba(13, 110, 253, .1);
    font-size: 1.1rem;
}

.inventory-filter-panel {
    background: #f8fafc;
    border-color: #dbe4ef;
}

.inventory-row td:first-child {
    border-left: 4px solid transparent;
}

.inventory-row-explosive td:first-child {
    border-left-color: #dc3545;
}

.inventory-row-disposal {
    background: #f1f3f5;
    color: #5c636a;
}

.inventory-row-disposal td:first-child {
    border-left-color: #343a40;
}

.inventory-mobile-card {
    border-left-width: 4px;
}

@media (max-width: 575.98px) {
    .inventory-location-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inventory-location-card {
        align-items: flex-start;
        padding: .65rem;
    }

    .inventory-location-icon {
        width: 1.9rem;
        height: 1.9rem;
    }

    .pagination .page-item:not(:first-child):not(:last-child):not(.active) {
        display: none;
    }

    .user-management-card .card-body {
        padding: .85rem;
    }
}

/* ── Search bar ── */
@media (max-width: 575.98px) {
    .input-group .form-control {
        font-size: 16px;
    }
}

/* ── Print styles ── */
@media print {
    .navbar, .mobile-bottom-nav, .btn, form {
        display: none !important;
    }
}
