/* =========================================================
   [ 1. GLOBAL & BACKGROUND ]
========================================================== */
body {
    margin: 0;
    font-family: 'Inter', 'Prompt', sans-serif;
    color: #334155;
    background: linear-gradient(-45deg, #e0c3fc, #8ec5fc, #e0c3fc, #c2e9fb);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 10px;
}

.swal2-container {
    z-index: 999999 !important;
}

.glass-swal {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    border-radius: 28px !important;
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
}

#main-loader {
    display: flex;
    position: fixed;
    inset: 0;
    background: #ffffff;
    z-index: 99999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    backdrop-filter: blur(15px);
}

#network-status-bar {
    display: none;
    background: #dc3545;
    color: white;
    text-align: center;
    padding: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    position: relative;
    z-index: 100000;
}

/* =========================================================
   [ 2. LOGIN PAGE & LOGOS ]
========================================================== */
.glass-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.glass-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#landing-page {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    background: linear-gradient(-45deg, #e0c3fc, #8ec5fc, #e0c3fc, #c2e9fb);
    background-size: 400% 400%;
}

.glass-login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 30px;
    padding: 50px 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: center;
    width: 90%;
    max-width: 420px;
    animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.username-input-wrapper {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 16px;
    padding: 0 20px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    height: 52px;
    transition: all 0.3s;
}

.username-input-wrapper:focus-within {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
}

.username-input-wrapper input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-family: 'Prompt', sans-serif;
    padding-left: 10px;
}

.username-domain-suffix {
    color: #64748b;
    font-weight: 500;
    pointer-events: none;
}

/* =========================================================
   [ 3. TOP NAVIGATION & MOBILE BOTTOM NAV ]
========================================================== */
#app-layout {
    display: none;
    flex-direction: column;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    position: relative;
    flex: 1;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    padding: 10px 25px;
    height: 75px;
    z-index: 1000;
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #334155;
    cursor: pointer;
}

.header-logo img {
    height: 65px;
    transition: 0.3s;
}

.header-logo h4 {
    margin: 0;
    font-weight: 800;
    letter-spacing: 1px;
    font-size: 1.4rem;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-item-group {
    position: relative;
}

.nav-item {
    cursor: pointer;
    padding: 10px 18px;
    border-radius: 50px;
    font-weight: 600;
    color: #64748b;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(248, 250, 252, 0.9);
    color: #3b82f6;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.03);
}

.header-nav .dropdown-menu {
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    padding: 10px;
    background: #ffffff;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    margin-top: 15px;
    min-width: 220px;
    border-top: 4px solid #3b82f6;
}

.header-nav .dropdown-item {
    border-radius: 8px;
    padding: 12px 15px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 2px;
    transition: 0.2s;
}

.header-nav .dropdown-item:hover,
.header-nav .dropdown-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.05);
}

.bottom-nav-item {
    flex: 0 0 33.3333% !important;
    max-width: 33.3333% !important;
    padding: 10px 0 !important;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

.bottom-nav-item i {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 3px;
}

.bottom-nav-item.active {
    color: #3b82f6;
    transform: translateY(-3px);
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    width: 100%;
    transition: all 0.4s ease;
}

.main-content {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    display: block;
}

.app-view {
    display: none;
    animation: fadeInView 0.3s ease-in-out forwards;
}

.app-view.active {
    display: block;
}

@keyframes fadeInView {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.glass-card h4 .bi,
button[id^="btn_cart_"] .bi,
.admin-btn-print .bi,
.modal-title .bi {
    display: none !important;
}

.admin-btn-stock .bi,
.admin-btn-store .bi,
.admin-btn-beanbag .bi,
.admin-btn-loaner .bi,
.admin-btn-fix .bi,
button[onclick^="window.fix_exportToImage"] .bi {
    display: none !important;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
}

/* =========================================================
   [ 4. FOOTER & NOTIFICATIONS ]
========================================================== */
.app-footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    height: 65px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.footer-left {
    display: flex;
    gap: 15px;
    align-items: center;
}

.footer-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    padding: 8px 18px;
    border-radius: 50px;
    transition: 0.3s;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
}

.btn-notif {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.btn-notif:hover {
    background: rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
}

.btn-line {
    background: #ffffff;
    color: #00B900;
    border: 1px solid #00B900;
}

.btn-line:hover {
    background: #00B900;
    color: #ffffff;
    transform: translateY(-2px);
}

.social-icons a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f8fafc;
    color: #475569;
    text-decoration: none;
    margin-left: 8px;
    border: 1px solid #e2e8f0;
    transition: 0.3s;
    font-size: 1rem;
}

.sc-fb:hover {
    background: #1877F2 !important;
    color: white !important;
    border-color: #1877F2 !important;
    transform: translateY(-3px);
}

.sc-ig:hover {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%) !important;
    color: white !important;
    border-color: #dc2743 !important;
    transform: translateY(-3px);
}

.sc-line:hover {
    background: #00B900 !important;
    color: white !important;
    border-color: #00B900 !important;
    transform: translateY(-3px);
}

.sc-email:hover {
    background: #ea4335 !important;
    color: white !important;
    border-color: #ea4335 !important;
    transform: translateY(-3px);
}

.sc-tel:hover {
    background: #0f172a !important;
    color: white !important;
    border-color: #0f172a !important;
    transform: translateY(-3px);
}

.notification-dropdown {
    position: absolute;
    top: 70px;
    right: 25px;
    width: 350px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: top right;
}

.notification-dropdown.show {
    display: flex;
    animation: dropUpFade 0.2s ease forwards;
}

@keyframes dropUpFade {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.notification-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(248, 250, 252, 0.8);
}

.notification-body {
    max-height: 350px;
    overflow-y: auto;
}

.notification-item {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
    display: flex;
    gap: 15px;
    cursor: pointer;
    transition: 0.2s;
    color: inherit;
    text-decoration: none;
}

.notification-item:hover {
    background-color: rgba(241, 245, 249, 0.8);
}

.notification-item.unread {
    background-color: rgba(239, 246, 255, 0.8);
}

.notification-item.unread::after {
    content: '';
    width: 10px;
    height: 10px;
    background-color: #3b82f6;
    border-radius: 50%;
    align-self: center;
    margin-left: auto;
}

/* =========================================================
   [ 5. CARDS & IMAGES (Card 1:1, Image 4:3) ]
========================================================== */
.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05);
    padding: 25px;
    margin-bottom: 25px;
}

.card-1x1-wrapper {
    aspect-ratio: 1 / 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.stock-product-card {
    cursor: pointer;
    background: #ffffff !important;
    border-radius: 20px !important;
    overflow: hidden;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.04) !important;
    border: 1px solid #e2e8f0 !important;
    transition: all 0.3s;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.stock-product-card:hover {
    transform: translateY(-6px);
    border-color: #3b82f6 !important;
    box-shadow: 0 15px 30px rgba(59, 130, 246, 0.15) !important;
}

.img-container {
    width: 100%;
    aspect-ratio: 4/3 !important;
    background: #f8fafc !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border-bottom: 1px solid #f1f5f9;
}

.img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover !important;
    transition: transform 0.4s ease;
}

.stock-product-card:hover .img-container img {
    transform: scale(1.05);
}

.status-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    font-size: 0.72rem;
    padding: 6px 12px;
    border-radius: 50px;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.card-out-of-stock {
    border: 2px solid #ef4444 !important;
    background: #fef2f2 !important;
}

.card-info-area {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.grid-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.grid-container .col {
    flex: 0 0 calc(100% / var(--grid-cols, 5) - 1rem);
    max-width: calc(100% / var(--grid-cols, 5) - 1rem);
}

@media (min-width: 577px) and (max-width: 768px) {
    .grid-container .col {
        flex: 0 0 calc(100% / 2 - 1rem);
        max-width: calc(100% / 2 - 1rem);
    }
}

@media (min-width: 769px) and (max-width: 1199px) {
    .grid-container .col {
        flex: 0 0 calc(100% / 3 - 1rem);
        max-width: calc(100% / 3 - 1rem);
    }
}

.input-group-custom {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 16px;
    overflow: hidden;
    height: 48px;
}

.input-group-custom i {
    padding-left: 18px;
    color: #94a3b8;
    font-size: 1.2rem;
}

.input-group-custom input {
    border: none;
    background: transparent;
    outline: none;
    padding-left: 12px;
    width: 100%;
}

.view-toggle-btn {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    padding: 8px 16px;
    cursor: pointer;
    color: #64748b;
    transition: 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.view-toggle-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

.view-toggle-btn-left {
    border-radius: 12px 0 0 12px;
    border-right: none;
}

.view-toggle-btn-right {
    border-radius: 0 12px 12px 0;
}

.list-view-mode .col {
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding: 0;
}

.list-view-mode {
    gap: 15px !important;
    margin: 0;
}

.list-view-mode .stock-product-card {
    flex-direction: row !important;
    height: auto !important;
    padding: 15px 30px !important;
    align-items: center;
    border-radius: 16px;
}

.list-view-mode .stock-product-card .card-1x1-wrapper {
    display: flex !important;
    flex-direction: row !important;
    aspect-ratio: auto !important;
    width: 100%;
    align-items: center;
}

.list-view-mode .stock-product-card .status-badge {
    position: static !important;
    margin-right: 30px !important;
    min-width: 120px;
    text-align: center;
    flex-shrink: 0;
}

.list-view-mode .stock-product-card .img-container {
    width: 90px !important;
    height: 90px !important;
    border-radius: 10px !important;
    margin-right: 40px !important;
    border: 1px solid #e2e8f0 !important;
    aspect-ratio: auto !important;
    flex-shrink: 0;
}

.list-view-mode .stock-product-card .card-info-area {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    padding: 0 !important;
    width: 100%;
    gap: 30px !important;
    text-align: left !important;
}

.list-view-mode .stock-product-card .card-info-area h6 {
    flex: 1 1 40%;
    margin: 0 !important;
}

.list-view-mode .stock-product-card .card-info-area>div {
    flex: 0 0 auto;
    margin: 0 !important;
}

@keyframes cartBump {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3) rotate(-10deg);
        color: #ffc107;
    }

    100% {
        transform: scale(1);
    }
}

.cart-bump {
    animation: cartBump 0.5s ease;
}

.grid-size-selector {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 0 10px;
    height: 40px;
    margin-left: 10px;
}

.grid-size-selector select {
    border: none;
    background: transparent;
    outline: none;
    font-weight: bold;
    color: #475569;
    cursor: pointer;
}

/* =========================================================
   [ 6. FIX SYSTEM TABLES & WATERMARKS ]
========================================================== */
.table-responsive {
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    overflow-x: auto;
}

.table th {
    background: rgba(241, 245, 249, 0.9);
    font-weight: 700;
    text-align: center;
    padding: 15px;
}

.table td {
    padding: 15px;
    vertical-align: middle;
    text-align: center;
}

.clickable-row {
    cursor: pointer;
    transition: 0.2s;
    position: relative;
}

.clickable-row:hover td {
    background-color: rgba(248, 250, 252, 0.9) !important;
}

.fix-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 15px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
}

.status-inbox {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.status-working {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.status-qc {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: white;
}

.status-done {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.watermark-cell {
    position: relative;
    overflow: hidden;
}

.watermark-cell::after {
    content: attr(data-watermark);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-8deg);
    font-size: 1.5rem;
    font-weight: 900;
    white-space: pre-wrap;
    text-align: center;
    pointer-events: none;
    z-index: 1;
    opacity: 0.15;
    width: 100%;
    letter-spacing: 1px;
}

.watermark-content {
    position: relative;
    z-index: 2;
}

.fix-row-default {
    background-color: #ffffff !important;
}

.fix-row-default td:first-child {
    border-left: 8px solid #cbd5e1;
}

.fix-row-inbox {
    background-color: #ffffff !important;
}

.fix-row-inbox td:first-child {
    border-left: 8px solid #3b82f6;
}

.fix-row-working {
    background-color: #ffffff !important;
}

.fix-row-working td:first-child {
    border-left: 8px solid #f59e0b;
}

.fix-row-overdue {
    background-color: #fef2f2 !important;
}

.fix-row-overdue td:first-child {
    border-left: 8px solid #ef4444;
}

.fix-row-overdue .watermark-cell::after {
    color: #ef4444;
    opacity: 0.2;
}

.fix-row-warning {
    background-color: #fffbeb !important;
}

.fix-row-warning td:first-child {
    border-left: 8px solid #f59e0b;
}

.fix-row-warning .watermark-cell::after {
    color: #f59e0b;
}

.fix-row-qc-sit {
    background-color: #f0f9ff !important;
}

.fix-row-qc-sit td:first-child {
    border-left: 8px solid #0ea5e9;
}

.fix-row-qc-sit .watermark-cell::after {
    color: #0ea5e9;
}

.fix-row-qc-del {
    background-color: #f0fdf4 !important;
}

.fix-row-qc-del td:first-child {
    border-left: 8px solid #10b981;
}

.fix-row-qc-del .watermark-cell::after {
    color: #10b981;
}

.fix-job-completed {
    opacity: 0.6;
    background-color: #f8fafc !important;
    filter: grayscale(20%);
}

.fix-job-completed td:first-child {
    border-left: 8px solid #94a3b8;
}

.fix-job-completed .watermark-cell::after {
    color: #94a3b8;
    opacity: 0.25;
}

#export-template-wrapper {
    position: absolute;
    top: -10000px;
    left: 0;
    width: 2200px;
    background: #ffffff;
    padding: 40px;
    z-index: -9999;
    display: block;
}

.export-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 18px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    table-layout: fixed;
}

.export-table th {
    background: #f1f5f9;
    color: #1e293b;
    padding: 20px 15px;
    border: 1px solid #e2e8f0;
    text-align: center;
    font-weight: 700;
}

.export-table td {
    padding: 20px 15px;
    vertical-align: middle;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.export-watermark-cell {
    position: relative;
    overflow: hidden;
}

.export-watermark-cell::after {
    content: attr(data-watermark);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-8deg);
    font-size: 2.8rem;
    font-weight: 900;
    white-space: pre-wrap;
    text-align: center;
    pointer-events: none;
    z-index: 1;
    opacity: 0.15;
    width: 100%;
}

/* =========================================================
   [ 7. MODALS & USER MANAGEMENT ]
========================================================== */
.modal-content {
    border-radius: 28px;
    border: none;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
}

.close-btn-custom {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
}

.close-btn-custom:hover {
    background: #ef4444;
    color: white;
}

.user-mng-card {
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: 0.3s;
}

.user-mng-card:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
    transform: translateY(-3px);
}

.user-status-pending {
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fde68a;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}

.user-status-approved {
    background: #dcfce7;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}

.user-status-rejected {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}

/* =========================================================
   [ 8. PRINT STYLES (A4) ]
========================================================== */
@media screen {
    .print-only {
        display: none !important;
    }
}

@media print {
    @page {
        margin: 1.5cm;
    }

    body {
        background: white !important;
        margin: 0;
        padding: 0;
        font-family: 'Sarabun', sans-serif !important;
    }

    body * {
        visibility: hidden;
    }

    .print-only,
    .print-only * {
        visibility: visible;
        font-family: 'Sarabun', sans-serif !important;
    }

    .print-only {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        color: #000;
    }

    .page-break-before {
        page-break-before: always !important;
    }

    .print-image-card {
        border: 1px solid #ccc;
        border-radius: 12px;
        padding: 15px;
        text-align: center;
        page-break-inside: avoid;
    }

    .print-image-card img {
        width: 100%;
        height: 200px;
        object-fit: contain;
        border-bottom: 1px solid #eee;
        margin-bottom: 10px;
    }
}

/* =========================================================
   [ 10. DELIVERY SYSTEM V2 (อัปเกรดใหม่) ]
========================================================== */
.del-filter-wrapper {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: none;
}

.del-filter-wrapper::-webkit-scrollbar {
    display: none;
}

.del-filter-btn {
    white-space: nowrap;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.3s;
}

.del-filter-btn:hover {
    background: #f1f5f9;
}

.del-filter-btn.active {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

.contact-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 15px;
    margin-bottom: 10px;
}

.contact-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.contact-group:last-child {
    margin-bottom: 0;
}

.contact-label {
    color: #64748b;
    width: 50px;
    flex-shrink: 0;
    font-weight: 600;
}

.contact-name {
    font-weight: 700;
    color: #1e293b;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.contact-actions {
    display: flex;
    gap: 6px;
}

.contact-btn {
    background: #e2e8f0;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.9rem;
}

.contact-btn:hover {
    background: #3b82f6;
    color: #fff;
    transform: scale(1.1);
}

.delivery-job-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    position: relative;
    margin-bottom: 15px;
    transition: 0.3s;
}

.delivery-job-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.delivery-job-card.completed {
    opacity: 0.7;
    background: #f8fafc;
}

.delivery-job-card.completed .del-body {
    filter: grayscale(40%);
}

.delivery-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    font-size: 2.5rem;
    font-weight: 900;
    opacity: 0;
    pointer-events: none;
    z-index: 99;
    white-space: nowrap;
    border: 4px solid;
    padding: 8px 25px;
    border-radius: 16px;
    transition: 0.5s;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    text-align: center;
    letter-spacing: 1px;
}

.delivery-job-card.completed .delivery-watermark {
    opacity: 1;
}

.delivery-watermark.success {
    color: #10b981;
    border-color: #10b981;
}

.delivery-watermark.working {
    color: #3b82f6;
    border-color: #3b82f6;
    opacity: 0.9;
}

.delivery-watermark.failed {
    color: #dc2626;
    border-color: #dc2626;
    opacity: 0.9;
}

.delivery-watermark.postponed {
    color: #f59e0b;
    border-color: #f59e0b;
    opacity: 0.9;
}

.delivery-watermark.parked {
    color: #64748b;
    border-color: #64748b;
    opacity: 0.95;
}

.delivery-watermark.unpaid {
    color: #dc2626;
    border-color: #dc2626;
    opacity: 0.9;
}

.del-header {
    background: #f8fafc;
    padding: 12px 15px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.del-header .bill-no {
    font-weight: 800;
    color: #1e293b;
    font-size: 1rem;
}

.del-body {
    padding: 15px;
}

.del-footer {
    background: #f8fafc;
    padding: 12px 15px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.del-action-btn {
    flex: 1;
    padding: 8px 0;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    transition: 0.2s;
}

.btn-del-start {
    background: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
}

.btn-del-start:hover {
    background: #3b82f6;
    color: #fff;
}

.btn-del-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.btn-del-success:hover {
    background: #16a34a;
    color: #fff;
}

.btn-del-issue {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.btn-del-issue:hover {
    background: #dc2626;
    color: #fff;
}

.del-trip-card {
    background: #fff;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.del-trip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px dashed #e2e8f0;
}

.del-trip-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #0f172a;
}

.del-trip-stats {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 20px;
}

.trip-images-container {
    display: flex;
    gap: 10px;
    height: 100px;
    width: 100%;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 15px;
}

.trip-driver-img,
.trip-car-img {
    height: 100%;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    object-fit: cover;
    cursor: zoom-in;
    transition: 0.2s;
}

.trip-driver-img {
    aspect-ratio: 3/4;
}

.trip-car-img {
    aspect-ratio: 4/3;
}

.trip-driver-img:hover,
.trip-car-img:hover {
    transform: scale(1.08);
    border-color: #3b82f6;
    z-index: 10;
    position: relative;
}

/* ========================================== */
/* 🖨️ PRINT: A4 Landscape Run Sheet (ใบสั่งงานจัดส่ง) */
/* ========================================== */
@media print {

    /* ซ่อนทุกอย่างบนหน้าเว็บ */
    body * {
        visibility: hidden;
    }

    /* แสดงเฉพาะพื้นที่พิมพ์ */
    #print_runsheet_container,
    #print_runsheet_container * {
        visibility: visible;
    }

    #print_runsheet_container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: #fff;
    }

    /* ตั้งค่าหน้ากระดาษ A4 แนวนอน */
    @page {
        size: A4 landscape;
        margin: 10mm 15mm;
    }

    .no-print {
        display: none !important;
    }

    /* สไตล์ตารางปริ้นท์ */
    .print-table {
        width: 100%;
        border-collapse: collapse;
        font-family: 'Sarabun', 'SarabunPSK', sans-serif;
        font-size: 14px;
        margin-bottom: 10px;
    }

    .print-table th,
    .print-table td {
        border: 1px solid #000;
        padding: 5px 8px;
        vertical-align: top;
    }

    .print-table th {
        background-color: #f2f2f2 !important;
        text-align: center;
        font-weight: bold;
        -webkit-print-color-adjust: exact;
        /* สำหรับ Chrome, Safari, Edge */
        print-color-adjust: exact;
        /* สำหรับมาตรฐานใหม่ Firefox ฯลฯ */
    }

    /* สไตล์หัวกระดาษ */
    .print-header {
        text-align: center;
        font-family: 'Sarabun', 'SarabunPSK', sans-serif;
        margin-bottom: 10px;
    }

    .print-header h3 {
        font-weight: bold;
        margin: 0 0 5px 0;
        font-size: 20px;
    }

    .print-header p {
        margin: 0;
        font-size: 14px;
        font-weight: bold;
    }

    /* สไตล์ข้อมูลรถด้านบน */
    .print-info-box {
        display: flex;
        justify-content: space-between;
        margin-bottom: 10px;
        font-family: 'Sarabun', sans-serif;
        font-size: 14px;
        font-weight: bold;
    }

    /* กล่อง Checkbox ในตาราง */
    .print-checkbox {
        display: inline-block;
        width: 14px;
        height: 14px;
        border: 1px solid #000;
        margin-right: 5px;
        vertical-align: middle;
    }

    /* สไตล์ส่วนตรวจสอบรถด้านล่าง */
    .print-checklist-footer {
        font-family: 'Sarabun', sans-serif;
        font-size: 13px;
        border: 1px solid #000;
        padding: 10px;
        margin-top: 15px;
        page-break-inside: avoid;
    }

    .signature-box {
        display: flex;
        justify-content: space-around;
        margin-top: 25px;
        font-weight: bold;
    }

    /* การตัดหน้ากระดาษ */
    .page-break {
        page-break-after: always;
    }
}

/* =========================================================
   [ 11. MOBILE RESPONSIVE (อัปเกรดสมบูรณ์ 100% จัดเรียงบรรทัดปกติ) ]
========================================================== */
@media (max-width: 768px) {

    /* 📌 1. โครงสร้างหลัก (Body & Layout) */
    body {
        overflow-x: hidden !important;
    }

    .main-content {
        padding: 12px !important;
        padding-bottom: 110px !important; /* ดันเนื้อหาหนีแถบข่าวด้านล่าง */
    }

    /* ป้องกัน iOS Zoom เวลากดพิมพ์ในช่อง Input/Select */
    input[type="text"],
    input[type="number"],
    input[type="password"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* 📌 2. ซ่อนเมนูด้านบนที่เทอะทะ และแสดงเฉพาะที่จำเป็น */
    .header-nav .dropdown-toggle span {
        display: none !important; /* ซ่อนชื่อ Profile */
    }
    
    #user-badge-role {
        display: none !important; /* ซ่อนตำแหน่ง */
    }

    .header-nav .nav-item-group,
    .header-nav .nav-item {
        display: none !important; /* ซ่อนเมนูข้อความ */
    }

    .dropdown.d-none.d-md-block {
        display: block !important; /* บังคับแสดง Dropdown สิทธิ์ */
    }

    #top_user_btn {
        padding: 4px !important;
        border-radius: 50% !important;
        width: 38px;
        height: 38px;
        display: flex !important;
        justify-content: center;
    }

    .header-nav > button.notification-bell,
    .header-nav > button#btn_global_history,
    .header-nav > button {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .header-nav {
        gap: 8px !important;
        justify-content: flex-end;
    }

    #main-top-logo {
        height: 35px !important;
    }

    .top-header {
        padding: 8px 12px !important;
        height: 60px !important;
    }

    .app-footer {
        display: none !important;
    }

    /* 📌 3. เมนูด้านล่าง (Bottom Nav) */
    .bottom-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        padding: 0;
        height: 65px !important;
        z-index: 1050 !important;
        background: rgba(255, 255, 255, 0.98) !important;
    }

    .bottom-nav::-webkit-scrollbar {
        display: none;
    }

    .bottom-nav-item {
        flex: 1 1 auto !important;
        min-width: 75px !important;
        max-width: none !important;
        padding: 10px 5px !important;
        border-right: 1px solid rgba(0, 0, 0, 0.05);
        font-size: 0.75rem !important;
        text-decoration: none;
        color: #64748b;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .bottom-nav-item:last-child {
        border-right: none;
    }

    .bottom-nav-item i,
    .bottom-nav-item span {
        font-size: 1.3rem !important;
        margin-bottom: 2px;
        display: block;
    }

    .news-ticker-bar {
        bottom: 65px !important;
        height: 30px !important;
        z-index: 1040 !important;
        background: rgba(255, 255, 255, 0.95) !important;
    }

    /* 📌 4. การจัดการ Modal (หน้าต่าง Pop-up ให้พอดีขอบ ไม่ล้น) */
    .modal-dialog {
        margin: 12px auto !important;
        width: calc(100% - 24px) !important;
        max-width: 500px !important;
    }

    .modal-content {
        border-radius: 20px !important;
    }

    .modal-body,
    .modal-header {
        padding: 15px !important;
    }

    .modal-title {
        font-size: 1.1rem !important;
    }

    .notification-dropdown {
        width: calc(100% - 30px) !important;
        right: 15px !important;
        left: 15px !important;
        top: 60px !important;
    }

    /* 📌 5. ปุ่มหมวดหมู่ให้เลื่อนซ้ายขวาได้ในมือถือ */
    .category-filter-wrapper {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scrollbar-width: none;
    }

    .category-filter-wrapper::-webkit-scrollbar {
        display: none;
    }

    /* 📌 6. ปรับขนาดการ์ดสินค้า และ Grid */
    #grid_stock, 
    #grid_store, 
    #grid_beanbag,
    #grid_loaner {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        margin-top: 10px !important;
        flex-direction: row !important;
    }

    #grid_stock > div, 
    #grid_store > div, 
    #grid_beanbag > div,
    #grid_loaner > div {
        flex: 0 0 calc(50% - 5px) !important;
        max-width: calc(50% - 5px) !important;
        width: 100% !important;
        padding: 0 !important;
    }

    #grid_fleet, 
    #delivery_trip_grid, 
    #fix_productGrid {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin-top: 10px !important;
    }

    #grid_fleet > div, 
    #delivery_trip_grid > div, 
    #fix_productGrid > div {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
    }

    .stock-product-card {
        flex-direction: column !important;
        padding: 8px 10px !important;
        height: 100% !important;
        align-items: stretch !important;
        border-radius: 14px !important;
    }

    .stock-product-card .card-1x1-wrapper {
        flex-direction: column !important;
        aspect-ratio: 1/1 !important;
        width: 100%;
        align-items: center;
    }

    .stock-product-card .img-container {
        width: 100% !important;
        height: auto !important;
        min-width: auto !important;
        border-radius: 8px !important;
        margin-right: 0 !important;
        margin-bottom: 8px !important;
        border: none !important;
        aspect-ratio: 4/3 !important;
    }

    .stock-product-card .status-badge {
        position: absolute !important;
        top: -6px !important;
        left: -6px !important;
        font-size: 0.6rem;
        padding: 3px 6px;
        transform: scale(0.9);
    }

    .stock-product-card .card-info-area {
        padding: 0 !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
        text-align: left;
        width: 100% !important;
        gap: 3px !important;
    }

    .stock-product-card h6 {
        font-size: 0.85rem !important;
        margin-bottom: 4px !important;
        white-space: normal !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden !important;
    }

    .stock-product-card .card-info-area > .d-flex.justify-content-center {
        justify-content: flex-start !important;
        margin: 2px 0 !important;
    }

    .stock-product-card .card-info-area .badge.border {
        font-size: 0.7rem !important;
        padding: 3px 6px !important;
        background: #f1f5f9 !important;
        color: #475569 !important;
        border-color: #cbd5e1 !important;
    }

    .stock-product-card .text-secondary.small {
        font-size: 0.7rem !important;
        text-align: left !important;
        margin: 0 !important;
    }

    .stock-product-card .mt-2.text-center {
        margin-top: auto !important;
        text-align: left !important;
        width: 100%;
    }

    .stock-product-card .btn-outline-primary {
        font-size: 0.75rem !important;
        padding: 4px !important;
        width: 100% !important;
    }

    .list-view-mode .col {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .list-view-mode .stock-product-card {
        flex-direction: row !important;
        padding: 10px !important;
        align-items: center !important;
    }

    .list-view-mode .stock-product-card .img-container {
        width: 80px !important;
        height: 80px !important;
        min-width: 80px !important;
        margin-right: 10px !important;
        margin-bottom: 0 !important;
        aspect-ratio: 1/1 !important;
    }

    .list-view-mode .stock-product-card .card-info-area {
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        text-align: left !important;
        width: calc(100% - 90px) !important;
    }

    .list-view-mode .stock-product-card .card-info-area > .d-flex.justify-content-center {
        justify-content: flex-start !important;
        margin: 2px 0 !important;
    }

    .list-view-mode .stock-product-card .mt-2.text-center {
        margin-top: 4px !important;
        text-align: left !important;
        width: 100%;
    }

    .list-view-mode .stock-product-card .btn-outline-primary {
        width: auto !important;
        padding: 4px 12px !important;
    }

    .price-badge,
    .promo-badge {
        font-size: 0.65rem !important;
        padding: 3px 8px !important;
        top: 6px !important;
        right: 6px !important;
    }

    /* 📌 7. หน้า Profile, Login และอื่นๆ */
    .profile-card-wrapper,
    #upd_user_left_panel {
        padding: 15px !important;
    }

    #upd_user_right_panel {
        padding: 10px !important;
        max-height: none !important;
    }

    .perm-module-box {
        padding: 12px !important;
        margin-bottom: 12px !important;
        border-radius: 12px !important;
    }

    .perm-module-header {
        padding-bottom: 8px !important;
        margin-bottom: 10px !important;
    }

    .perm-item {
        padding: 8px 12px !important;
    }

    .perm-item-text {
        font-size: 0.85rem !important;
    }

    .glass-login-card {
        padding: 20px !important;
        width: 90% !important;
        max-width: 360px !important;
        margin-top: -30px;
        max-height: 85vh !important; /* ล็อกความสูงไม่ให้เกิน 85% ของจอ */
        overflow-y: auto !important; /* ถ้ายาวไปให้เลื่อนได้ */
    }

    .swal2-popup.glass-swal {
        width: 92% !important;
        max-width: 380px !important;
        padding: 1.5em 1em !important;
        max-height: 85vh !important; /* ล็อกความสูง Popup หลัก */
        overflow-y: auto !important;
    }
    
    .swal2-html-container {
        max-height: 60vh !important; /* ล็อกความสูงกล่องข้อความข้างใน */
        overflow-y: auto !important;
    }

    .delivery-job-card .card-body,
    .del-body,
    .del-header,
    .del-footer {
        padding: 12px !important;
    }

    .trip-images-container {
        justify-content: flex-start !important;
        margin-top: 10px;
        height: 60px !important;
    }

    .delivery-watermark {
        font-size: 1.3rem !important;
        padding: 6px 12px !important;
        border-width: 3px !important;
    }

    .view-toggle-btn {
        padding: 4px 10px !important;
    }

    .grid-size-selector {
        display: none !important;
    }

    .input-group-custom {
        height: 42px !important;
    }

    select.form-select {
        height: 42px !important;
        font-size: 0.85rem !important;
    }

    #view-announcements .glass-card {
        padding: 15px !important;
        min-height: auto !important;
    }

    #annTab {
        flex-direction: column;
        width: 100% !important;
    }

    #annTab .btn {
        width: 100% !important;
        padding: 8px !important;
        font-size: 0.9rem;
    }

    .date-group-container {
        padding: 10px !important;
        margin-bottom: 15px !important;
    }
}

/* =========================================================
   [ 12. THEME: LUXURY RBAC & USER CARDS ]
========================================================== */
.user-card-luxury {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 25px;
    border: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    cursor: pointer;
}

.user-card-luxury:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

.user-card-luxury::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    transition: 0.4s;
}

.card-role-ceo::before {
    background: linear-gradient(90deg, #d4af37, #fef08a);
}

.card-role-admin::before {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.card-role-logistic::before {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.card-role-sales::before {
    background: linear-gradient(90deg, #8b5cf6, #c084fc);
}

.card-role-pending::before {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.user-card-luxury:hover::before {
    height: 100%;
    opacity: 0.05;
}

.role-icon-glow {
    width: 65px;
    height: 65px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.5);
}

.icon-ceo {
    background: #fffbeb;
    color: #d4af37;
    border: 1px solid #fef08a;
}

.icon-admin {
    background: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
}

.icon-logistic {
    background: #f0fdf4;
    color: #10b981;
    border: 1px solid #bbf7d0;
}

.icon-sales {
    background: #faf5ff;
    color: #8b5cf6;
    border: 1px solid #e9d5ff;
}

.icon-pending {
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
}

.perm-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.perm-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.perm-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 34px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.perm-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.perm-toggle input:checked+.perm-slider {
    background-color: #10b981;
}

.perm-toggle input:disabled+.perm-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.perm-toggle input:checked+.perm-slider:before {
    transform: translateX(24px);
}

.perm-module-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.perm-module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed #e2e8f0;
    padding-bottom: 12px;
    margin-bottom: 15px;
}

.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 15px;
}

.perm-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    padding: 12px 15px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    transition: 0.3s;
}

.perm-item:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.perm-item-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.perm-request-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    cursor: pointer;
    border-radius: 12px;
}

.perm-request-overlay:hover {
    background: rgba(59, 130, 246, 0.05);
    border: 1px dashed #3b82f6;
}

/* =========================================================
   [ 13. ADMIN TOOLS & DASHBOARD ]
========================================================== */
.admin-toggle-btn {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 12px;
    transition: 0.3s;
    margin-left: 5px;
}

.admin-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.admin-chevron {
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.admin-chevron.rotated {
    transform: rotate(180deg);
}

.admin-collapse-area {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.admin-collapse-area.expanded {
    max-height: 400px;
}

.admin-collapse-area .menu-item {
    padding: 10px 15px;
    margin-left: 15px;
    font-size: 0.9rem;
    border-radius: 12px;
    margin-bottom: 4px;
}

.admin-tool-card {
    background: #ffffff;
    border-radius: 24px;
    padding: 30px 20px;
    border: 1px solid #e2e8f0;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.admin-tool-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    border-color: #3b82f6;
}

.admin-tool-icon {
    width: 80px;
    height: 80px;
    border-radius: 22px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    transition: 0.3s;
}

.admin-tool-card:hover .admin-tool-icon {
    transform: scale(1.1);
}

/* =========================================================
   [ 14. FLEET MANAGEMENT V2 ]
========================================================== */
.fleet-card {
    background: #ffffff !important;
    border-radius: 20px !important;
    overflow: hidden;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.04) !important;
    border: 1px solid #e2e8f0 !important;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 400px;
    position: relative;
}

.fleet-card:hover {
    transform: translateY(-6px);
    border-color: #3b82f6 !important;
    box-shadow: 0 15px 30px rgba(59, 130, 246, 0.15) !important;
}

.fleet-img-wrapper {
    width: 100%;
    aspect-ratio: 4/3;
    background: #f8fafc;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f1f5f9;
}

.fleet-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease;
}

.fleet-card:hover .fleet-img-wrapper img {
    transform: scale(1.05);
}

.fleet-watermark-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    pointer-events: none;
    gap: 10px;
}

.wm-alert-box {
    transform: rotate(-15deg);
    padding: 8px 20px;
    border-radius: 12px;
    font-weight: 900;
    font-size: 1.1rem;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    opacity: 0.85;
}

.wm-warning {
    background: rgba(254, 240, 138, 0.9);
    color: #b45309;
    border: 2px solid #f59e0b;
    animation: pulse-wm 2s infinite;
}

.wm-danger {
    background: rgba(254, 202, 202, 0.9);
    color: #b91c1c;
    border: 2px solid #ef4444;
    animation: shake-wm 0.5s infinite alternate;
}

@keyframes pulse-wm {
    0% {
        transform: rotate(-15deg) scale(1);
    }

    50% {
        transform: rotate(-15deg) scale(1.05);
    }

    100% {
        transform: rotate(-15deg) scale(1);
    }
}

@keyframes shake-wm {
    0% {
        transform: rotate(-15deg) translateX(0);
    }

    100% {
        transform: rotate(-15deg) translateX(3px);
    }
}

.list-view-mode .fleet-card {
    flex-direction: row !important;
    min-height: auto;
    height: auto !important;
    padding: 15px;
    align-items: center;
}

.list-view-mode .fleet-img-wrapper {
    width: 150px;
    height: 110px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-right: 20px;
    flex-shrink: 0;
}

.list-view-mode .fleet-info-area {
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    padding: 0 !important;
    gap: 20px;
}

.list-view-mode .fleet-info-text {
    text-align: left !important;
    flex: 1;
}

.list-view-mode .fleet-actions {
    margin-top: 0 !important;
    width: auto !important;
}

.list-view-mode .fleet-watermark-overlay {
    background: rgba(255, 255, 255, 0.75);
}

.list-view-mode .wm-alert-box {
    font-size: 0.9rem;
    padding: 4px 10px;
}

/* =========================================================
   [ 15. DARK MODE OVERRIDES ]
========================================================== */
[data-bs-theme="dark"] body {
    background: linear-gradient(-45deg, #0f172a, #1e1e2f, #0f172a, #020617) !important;
    color: #f8fafc;
}

[data-bs-theme="dark"] .glass-card,
[data-bs-theme="dark"] .top-header,
[data-bs-theme="dark"] .bottom-nav,
[data-bs-theme="dark"] .app-footer,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .glass-login-card {
    background: rgba(30, 41, 59, 0.85) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #f8fafc;
}

[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .stock-product-card,
[data-bs-theme="dark"] .fleet-card,
[data-bs-theme="dark"] .admin-tool-card,
[data-bs-theme="dark"] .delivery-job-card,
[data-bs-theme="dark"] .perm-module-box,
[data-bs-theme="dark"] .user-mng-card,
[data-bs-theme="dark"] .date-group-container,
[data-bs-theme="dark"] .alert-warning,
[data-bs-theme="dark"] .alert-info,
[data-bs-theme="dark"] .alert-danger,
[data-bs-theme="dark"] .alert-success {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .text-dark,
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-bs-theme="dark"] h6 {
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .text-secondary {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .text-primary {
    color: #60a5fa !important;
}

[data-bs-theme="dark"] .text-success {
    color: #34d399 !important;
}

[data-bs-theme="dark"] .text-danger {
    color: #f87171 !important;
}

[data-bs-theme="dark"] .text-warning {
    color: #fbbf24 !important;
}

[data-bs-theme="dark"] .text-info {
    color: #38bdf8 !important;
}

[data-bs-theme="dark"] .input-group-custom,
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .swal2-input,
[data-bs-theme="dark"] .swal2-textarea {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .input-group-custom input {
    color: #f8fafc;
}

[data-bs-theme="dark"] .img-container,
[data-bs-theme="dark"] .fleet-img-wrapper,
[data-bs-theme="dark"] .trip-car-img,
[data-bs-theme="dark"] .trip-driver-img {
    background-color: #0f172a !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item.active {
    background-color: #334155 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .table-responsive {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .table {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table thead th,
[data-bs-theme="dark"] .table-secondary {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .table td {
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover td {
    background-color: #334155 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-outline-dark {
    color: #f8fafc !important;
    border-color: #f8fafc !important;
}

[data-bs-theme="dark"] .btn-outline-dark:hover {
    background-color: #f8fafc !important;
    color: #0f172a !important;
}

[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .bg-white {
    background-color: #1e293b !important;
}

[data-bs-theme="dark"] .border {
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .perm-item {
    background-color: #0f172a !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .perm-item-text,
[data-bs-theme="dark"] .perm-item-text.text-dark,
[data-bs-theme="dark"] .perm-item-text.text-muted {
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .del-filter-btn {
    background: #1e293b;
    color: #94a3b8;
    border-color: #334155;
}

[data-bs-theme="dark"] .del-filter-btn.active {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

[data-bs-theme="dark"] .del-trip-card {
    background: #1e293b;
    border-color: #334155;
}

[data-bs-theme="dark"] .del-trip-header {
    border-bottom-color: #334155;
}

[data-bs-theme="dark"] .del-trip-title {
    color: #f8fafc;
}

[data-bs-theme="dark"] .del-trip-stats {
    background: #0f172a;
    color: #94a3b8;
}

[data-bs-theme="dark"] .contact-box {
    background: #0f172a;
    border-color: #334155;
}

[data-bs-theme="dark"] .contact-name {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .contact-btn {
    background: #1e293b;
    color: #60a5fa;
}

[data-bs-theme="dark"] .contact-btn:hover {
    background: #3b82f6;
    color: #fff;
}

[data-bs-theme="dark"] .del-header,
[data-bs-theme="dark"] .del-footer {
    background: #1e293b;
    border-color: #334155;
}

[data-bs-theme="dark"] .btn-del-start {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}

[data-bs-theme="dark"] .btn-del-success {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

[data-bs-theme="dark"] .btn-del-issue {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

/* =========================================================
   [ 16. LINE FLEX MESSAGE MOCKUP (DASHBOARD PREVIEW) ]
========================================================== */
.preview-mode-pc .phone-mockup-container {
    width: 100%;
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.preview-mode-pc .phone-mockup-container::before {
    display: none;
}

.preview-mode-pc .phone-screen-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    padding: 0;
    overflow-y: visible;
}

.preview-mode-pc .line-flex-bubble {
    width: 100%;
    max-width: 400px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    text-align: left;
}

.preview-mode-mobile .phone-mockup-container {
    width: 320px;
    height: 600px;
    border: 12px solid #1e293b;
    border-radius: 36px;
    position: relative;
    background: #8fa9c4;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    margin: 0 auto;
}

.preview-mode-mobile .phone-mockup-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 20px;
    background: #1e293b;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    z-index: 10;
}

.preview-mode-mobile .phone-screen-container {
    height: 100%;
    width: 100%;
    overflow-y: auto;
    padding: 40px 15px 20px 15px;
    scrollbar-width: none;
}

.preview-mode-mobile .phone-screen-container::-webkit-scrollbar {
    display: none;
}

.preview-mode-mobile .line-flex-bubble {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    text-align: left;
    margin-bottom: 12px;
    width: 85%;
    margin-right: auto;
}

.flex-header {
    padding: 10px 12px;
    color: white;
    text-align: center;
}

.flex-body {
    padding: 12px;
    font-size: 0.8rem;
    color: #334155;
}

.flex-separator {
    height: 1px;
    background: #e2e8f0;
    margin: 8px 0;
}

.flex-btn-group {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.flex-btn {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    background: #f1f5f9;
    color: #3b82f6;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: none;
    border: none;
}

.flex-btn:hover {
    background: #e2e8f0;
}

/* ==========================================
   [ PRICE BADGES ]
========================================== */
.price-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #0f172a, #000000);
    color: #fbbf24;
    border: 1px solid #d97706;
    font-size: 0.72rem;
    padding: 6px 12px;
    border-radius: 50px;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    z-index: 10;
    letter-spacing: 0.5px;
}

.promo-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #ffffff;
    border: 2px solid #fca5a5;
    font-size: 0.72rem;
    padding: 6px 12px;
    border-radius: 50px;
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    z-index: 10;
    animation: pulse-promo 1.5s infinite;
}

@keyframes pulse-promo {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
        transform: scale(1);
    }
}

/* ========================================== */
/* 📺 NEWS TICKER FOOTER */
/* ========================================== */
.news-ticker-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
    z-index: 1020;
    display: flex;
    align-items: center;
    overflow: hidden;
    pointer-events: none;
}

@media (max-width: 991.98px) {
    .news-ticker-bar {
        bottom: 75px;
        /* หลบ Bottom Nav */
        background: rgba(255, 255, 255, 0.85);
        height: 30px;
    }
}

.ticker-content {
    white-space: nowrap;
    font-weight: bold;
    font-size: 14px;
    color: #dc2626;
    padding-left: 100%;
    animation: tickerScroll 90s linear infinite;
    text-shadow: 1px 1px 0px #fff;
}

@keyframes tickerScroll {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* =========================================================
   [ 18. CATEGORY BUTTONS & MOBILE CARD COMPRESSION ]
========================================================== */
/* แถบปุ่มหมวดหมู่ เลื่อนซ้ายขวาได้ */
.category-filter-wrapper {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-filter-wrapper::-webkit-scrollbar {
    display: none;
}

.cat-filter-btn {
    white-space: nowrap;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    flex-shrink: 0;
}

.cat-filter-btn:hover {
    background: #e2e8f0;
}

.cat-filter-btn.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.25);
    transform: translateY(-2px);
}

/* 📌 บีบการ์ดมือถือ และแยกรหัสกับสีลงมาด้านล่าง */
@media (max-width: 768px) {
    .grid-container {
        gap: 10px !important;
    }

    .stock-product-card {
        padding: 8px 10px !important;
        /* ลด padding ให้การ์ดกระชับขึ้น */
        border-radius: 14px !important;
    }

    .stock-product-card .img-container {
        width: 75px !important;
        height: 75px !important;
        min-width: 75px !important;
        margin-right: 10px !important;
    }

    .stock-product-card .card-info-area {
        width: calc(100% - 85px);
        gap: 3px !important;
        /* ลดช่องว่างระหว่างองค์ประกอบ */
    }

    .stock-product-card h6 {
        font-size: 0.9rem !important;
        /* ย่อขนาดชื่อสินค้าลงนิดนึง */
        margin-bottom: 2px !important;
        white-space: normal !important;
        /* ยอมให้ชื่อขึ้นบรรทัดใหม่ได้ถ้ายาวไป */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden !important;
        /* 🌟 ต้องมี overflow: hidden ไม่งั้นข้อความไม่ยอมตัด */
    }

    /* 🌟 จัดการ รหัส PO และ สี ให้ตกลงมาคนละบรรทัดสวยๆ */
    .stock-product-card .card-info-area>.d-flex.justify-content-center {
        justify-content: flex-start !important;
        /* ชิดซ้าย */
        margin: 2px 0 !important;
    }

    .stock-product-card .card-info-area .badge.border {
        font-size: 0.7rem !important;
        padding: 3px 6px !important;
        background: #f1f5f9 !important;
        /* เปลี่ยนสีพื้นหลังให้กลืนๆ */
        color: #475569 !important;
        border-color: #cbd5e1 !important;
    }

    .stock-product-card .text-secondary.small {
        font-size: 0.7rem !important;
        text-align: left !important;
        margin: 0 !important;
    }

    /* บีบปุ่มหยิบใส่ตะกร้า */
    .stock-product-card .mt-2.text-center {
        margin-top: 4px !important;
        text-align: left !important;
    }

    .stock-product-card .btn-outline-primary {
        font-size: 0.75rem !important;
        padding: 4px 10px !important;
        width: auto !important;
        /* ไม่ต้องเต็มจอ ให้พอดีคำ */
    }

    /* ดันป้ายราคากับสถานะให้เล็กลงอีก */
    .price-badge,
    .promo-badge {
        font-size: 0.65rem !important;
        padding: 3px 8px !important;
        top: 6px !important;
        right: 6px !important;
    }
}