body {
    background: #f4f7f9;
    font-size: 13px;
}

#loadingScrn {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
}

.search-res {
    position: absolute;
    width: 100%;
    z-index: 1060;
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.toast-container {
    z-index: 2000;
}

.nav-pills .nav-link {
    font-weight: 600;
    color: #555;
    border-radius: 8px;
}

.nav-pills .nav-link.active {
    background: #0d6efd;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.card {
    border-radius: 12px;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.money-label {
    font-weight: 600;
    color: #666;
    width: 120px;
}

.money-val {
    text-align: right;
    flex-grow: 1;
    font-weight: bold;
}

.no-spinner::-webkit-outer-spin-button,
.no-spinner::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.no-spinner[type=number] {
    -moz-appearance: textfield;
}

.input-group>.no-spinner {
    border-left: 0;
    border-right: 0;
}

input.form-check-input.dt-select-checkbox {
    transform: scale(1.3);
}

table.table.dataTable.table-striped>tbody>tr:nth-of-type(2n+1).selected>* {
    box-shadow: inset 0 0 0 9999px rgba(13, 110, 253, 0.4);
}

table.table.dataTable.table-striped>tbody>tr:nth-of-type(2n).selected>* {
    box-shadow: inset 0 0 0 9999px rgba(13, 110, 253, 0.4);
}

.receipt-container {
    max-width: 100%;
    padding: 10px;
    font-size: 14px;
}

.receipt-container .table th,
.receipt-container .table td {
    vertical-align: middle;
    text-align: center;
}

#paymentMethod .form-check {
    margin-right: 1rem;
}

#paymentMethod .form-check-label {
    font-weight: 500;
    margin-left: 0.25rem;
}

div#dropzone-container {
    min-height: 300px;
    transition: all 0.3s ease;
}

#dropzone-container.drag-active {
    background-color: #e3f2fd !important;
    border: 3px dashed #0d6efd !important;
    transform: scale(1.02);
}

#dropzone-area:hover {
    background-color: #f1f3f5;
}

#invoiceTable_wrapper .dt-search {
    display: flex !important;
    align-items: center;
    gap: 5px;
}

#invoiceTable_wrapper .dt-search input {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

#btn-invc-filter {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-left: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    background-color: #fff;
    border: 1px solid #dee2e6;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.invc-filter-popup {
    position: absolute;
    top: 24%;
    right: 100px;
    width: 320px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 1060;
    padding: 15px;
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.invc-filter-popup.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.invc-filter-popup::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 16px;
    width: 12px;
    height: 12px;
    background: white;
    border-top: 1px solid #dee2e6;
    border-left: 1px solid #dee2e6;
    transform: rotate(45deg);
}

#invoiceTable_wrapper .dt-search .input-group {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#invoiceTable_wrapper .dt-search .input-group:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

#invoiceTable_wrapper .dt-search .input-group input,
#invoiceTable_wrapper .dt-search .input-group #btn-invc-filter {
    border: none !important;
    box-shadow: none !important;
    background-color: transparent;
}

.round-end-input {
    border-start-end-radius: .375rem !important;
    border-end-end-radius: .375rem !important;
}

.icon-btn {
    border: none;
    background: transparent;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: inherit;
}

.view-btn {
    color: var(--bs-primary);
}

.edit-btn {
    color: var(--bs-warning);
}

.delete-btn {
    color: var(--bs-danger);
}

.view-btn:hover {
    background-color: var(--bs-primary);
    color: #fff;
}

.edit-btn:hover {
    background-color: var(--bs-warning);
    color: #fff;
}

.delete-btn:hover {
    background-color: var(--bs-danger);
    color: #fff;
}

#dropzone-area {
    cursor: pointer;
}

#disable-dropzone-area {
    cursor: not-allowed;
    background-color: #D3D3D3;
}

#preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#imgUrlBtn {
    text-decoration: underline;
    font-size: small;
}

.user-profile-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    background: #fff;
    border-radius: 50px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: background 0.2s;
}

.user-profile-header:hover {
    background: #f8f9fa;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #dee2e6;
    flex-shrink: 0;
}

.user-email {
    font-size: 12px;
    color: #444;
    line-height: 1.3;
}

/* Gallery Images Styling */
.gallery-item {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
}

.gallery-item label {
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.gallery-item label:hover:not(.disabled) {
    background-color: #e7f1ff !important;
    border-color: #0d6efd !important;
}

/* Gallery item without image - shows plus icon */
.gallery-item label i {
    font-size: 1.5rem;
}

/* Gallery item with image - show preview */
.gallery-preview:not(.d-none) {
    display: block !important;
    cursor: pointer;
}

/* Gallery item without image (disabled state) */
.gallery-item.gallery-empty label {
    background: #e9ecef !important;
    border-color: #adb5bd !important;
    cursor: not-allowed;
    opacity: 0.6;
}

.gallery-item.gallery-empty label i {
    font-size: 1.2rem;
    color: #6c757d;
}

.gallery-item.gallery-empty label::after {
    content: '⊘';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    color: #6c757d;
    font-weight: bold;
}

.logout-btn {
    color: #dc3545;
    cursor: pointer;
    font-size: 18px;
    margin-left: 5px;
}

.logout-btn:hover {
    color: #a71d2a;
}

/* DataTable responsive buttons fix */
.dt-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

.dt-buttons .btn {
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.dt-buttons .btn.dropdown-toggle::after {
    margin-left: 0.25rem;
}

/* Fix DataTable layout on small screens */
@media (max-width: 768px) {
    .dt-buttons {
        flex-direction: column;
        width: 100%;
    }

    .dt-buttons .btn {
        width: 100%;
        font-size: 0.85rem;
        padding: 0.375rem 0.75rem;
    }

    .dt-buttons .dropdown-menu {
        width: 100% !important;
        max-width: calc(100vw - 1rem);
        right: 0 !important;
        left: auto !important;
    }
}

/* ════════ MOBILE & TABLET RESPONSIVE ════════ */

/* Tablet (768px - 992px) */
@media (min-width: 768px) and (max-width: 991px) {
    body {
        font-size: 12px;
        padding: 0.5rem;
    }

    .nav-pills .nav-link {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .card {
        margin-bottom: 0.75rem;
    }

    .modal-body {
        padding: 0.75rem;
    }

    .form-label {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }

    .form-control, .form-select {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }

    .btn {
        font-size: 0.85rem;
        padding: 0.35rem 0.65rem;
    }

    .user-profile-header {
        padding: 6px 10px;
        gap: 8px;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
    }

    .user-email {
        font-size: 11px;
    }

    #branch-bar {
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .icon-btn {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    table.dataTable {
        font-size: 0.8rem;
    }

    table.dataTable th, table.dataTable td {
        padding: 0.4rem 0.5rem;
    }

    /* POS cart adjustments */
    .money-label {
        width: auto;
        font-size: 0.85rem;
    }

    .money-val {
        font-size: 1rem;
    }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
    * {
        box-sizing: border-box;
    }

    body {
        font-size: 12px;
        padding: 0.5rem;
    }

    /* ──── Navigation ──── */
    .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .nav-pills {
        width: 100%;
        gap: 0.25rem;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
    }

    .nav-pills .nav-link {
        padding: 0.35rem 0.5rem;
        font-size: 0.7rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    #branch-bar {
        width: 100%;
        justify-content: flex-start;
        gap: 0.4rem;
        font-size: 0.75rem;
        margin-top: 0.5rem;
    }

    #branch-bar select {
        font-size: 0.75rem;
        padding: 0.25rem 0.4rem;
        min-width: auto;
    }

    #branchFilter {
        min-width: 5rem;
    }

    #writeBranch {
        min-width: 4rem;
    }

    .user-profile-header {
        padding: 4px 8px;
        gap: 6px;
        font-size: 0.7rem;
    }

    .user-avatar {
        width: 24px;
        height: 24px;
    }

    .user-email {
        font-size: 10px;
        line-height: 1.2;
    }

    .logout-btn {
        font-size: 14px;
        margin-left: 4px;
    }

    /* ──── Forms & Modals ──── */
    .modal-content {
        border-radius: 8px;
    }

    .modal-header {
        padding: 0.5rem 1rem;
    }

    .modal-header h5 {
        font-size: 0.9rem;
    }

    .modal-body {
        padding: 0.75rem;
    }

    .modal-footer {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .form-label {
        font-size: 0.8rem;
        margin-bottom: 0.2rem;
        font-weight: 500;
    }

    .form-control, .form-select, input[type="text"], input[type="email"], textarea {
        font-size: 0.85rem;
        padding: 0.35rem 0.5rem;
        border-radius: 0.3rem;
    }

    .form-check {
        margin-bottom: 0.5rem;
    }

    .form-check-label {
        font-size: 0.8rem;
        margin-left: 0.4rem;
    }

    /* ──── Buttons ──── */
    .btn, button {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
        border-radius: 0.25rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .icon-btn {
        width: 24px;
        height: 24px;
        font-size: 0.85rem;
    }

    .dt-buttons {
        flex-direction: column;
        width: 100%;
        gap: 0.3rem;
    }

    .dt-buttons .btn {
        width: 100%;
        margin-bottom: 0;
    }

    .dt-buttons .dropdown-menu {
        width: calc(100vw - 1rem) !important;
        max-width: 100%;
        right: auto !important;
        left: -0.5rem !important;
    }

    /* ──── Tables ──── */
    table.dataTable {
        font-size: 0.75rem;
        width: 100% !important;
    }

    table.dataTable thead th,
    table.dataTable tbody td {
        padding: 0.3rem 0.4rem;
    }

    table.dataTable_wrapper {
        overflow-x: auto;
    }

    /* DataTables scrolling */
    .dataTables_wrapper .dataTables_scroll {
        overflow-x: auto;
    }

    /* ──── Cards ──── */
    .card {
        border-radius: 8px;
        margin-bottom: 0.5rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .card-header {
        padding: 0.5rem 0.75rem;
    }

    .card-header h6 {
        font-size: 0.85rem;
        margin: 0;
    }

    .card-body {
        padding: 0.75rem;
    }

    /* ──── POS Cart Layout ──── */
    #tabPosLayout {
        flex-direction: column;
    }

    #posLeftPanel {
        flex: 0 0 auto;
        margin-bottom: 1rem;
    }

    #posCartPanel {
        flex: 1 1 auto;
    }

    .money-label {
        width: auto;
        font-size: 0.75rem;
    }

    .money-val {
        font-size: 0.9rem;
        text-align: right;
    }

    #paymentMethod {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    #paymentMethod .form-check {
        margin-right: 0;
    }

    #paymentMethod .form-check-label {
        font-size: 0.75rem;
    }

    /* ──── Image Upload ──── */
    #dropzone-container {
        min-height: 150px;
        border-radius: 8px;
    }

    #dropzone-area, #disable-dropzone-area {
        padding: 1rem 0.5rem !important;
    }

    #dropzone-area i {
        font-size: 1.5rem;
    }

    #dropzone-area p {
        font-size: 0.8rem;
    }

    /* ──── Gallery Images ──── */
    .gallery-item {
        max-width: 60px;
        height: 60px;
    }

    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* ──── Input Groups ──── */
    .input-group {
        flex-wrap: wrap;
    }

    .input-group > .form-control,
    .input-group > .form-select {
        min-width: 0;
        flex: 1 1 auto;
    }

    /* ──── Responsive Columns ──── */
    .col-md-4, .col-md-6, .col-md-3 {
        width: 100% !important;
        max-width: 100%;
    }

    .row {
        margin-right: -0.5rem;
        margin-left: -0.5rem;
    }

    .row > div {
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }

    /* ──── Search & Filter ──── */
    #invoiceTable_wrapper .dt-search {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    #invoiceTable_wrapper .dt-search input {
        width: 100%;
        font-size: 0.8rem;
        padding: 0.35rem 0.5rem;
    }

    .invc-filter-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        width: 90vw;
        max-width: 300px;
        transform: translate(-50%, -50%);
        z-index: 2000;
    }

    /* ──── Modal Adjustments ──── */
    .modal-xl, .modal-lg, .modal-dialog {
        margin: 0.5rem;
    }

    .modal-xl .modal-content, .modal-lg .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }

    /* ──── Receipt/Print ──── */
    .receipt-container {
        max-width: 100%;
        padding: 0.5rem;
        font-size: 12px;
    }

    .receipt-container .table {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .receipt-container .table th,
    .receipt-container .table td {
        padding: 0.3rem 0.25rem;
        font-size: 0.75rem;
    }

    /* ──── DataTable Controls ──── */
    .dt-paging {
        padding: 0.5rem 0;
    }

    .dt-paging .pagination {
        gap: 0.2rem;
    }

    .dt-paging .pagination .page-link {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }

    /* ──── Checkboxes ──── */
    input.form-check-input.dt-select-checkbox {
        width: 16px;
        height: 16px;
        transform: scale(1);
    }
}