/* Tab Bảng giá — chỉ mobile ≤768px (desktop không đổi) */

@media (min-width: 769px) {
    #priceboard-tab .pb-mobile-scroll-hint {
        display: none !important;
    }
}

@media (max-width: 768px) {
    #priceboard-tab.tab-content.active {
        display: block;
        width: 100%;
        min-height: calc(100dvh - var(--str-tabs-height, 52px));
        overflow-x: hidden;
    }

    #priceboard-tab .priceboard-container {
        padding: 10px 10px calc(12px + env(safe-area-inset-bottom, 0px));
        gap: 12px;
        border-radius: 12px;
    }

    /* Chỉ số đầu trang */
    #priceboard-tab .pb-index-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    #priceboard-tab .pb-index-card {
        padding: 12px;
    }

    #priceboard-tab .pb-index-price {
        font-size: 18px;
    }

    #priceboard-tab .pb-index-change {
        font-size: 12px;
    }

    /* Toolbar: tìm kiếm trên, danh mục cuộn ngang */
    #priceboard-tab .pb-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px;
    }

    #priceboard-tab .pb-search-box {
        order: -1;
        width: 100%;
        min-width: 0;
    }

    #priceboard-tab .pb-search-input {
        min-height: 44px;
        font-size: 16px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    #priceboard-tab .pb-categories {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 8px;
        padding-bottom: 2px;
        margin: 0 -2px;
    }

    #priceboard-tab .pb-categories::-webkit-scrollbar {
        display: none;
    }

    #priceboard-tab .pb-cat-btn {
        flex: 0 0 auto;
        padding: 10px 14px;
        font-size: 12px;
        min-height: 40px;
        white-space: nowrap;
        touch-action: manipulation;
    }

    #priceboard-tab .pb-mobile-scroll-hint {
        display: block;
        margin: 0 0 6px;
        padding: 0 4px;
        font-size: 11px;
        font-weight: 600;
        color: var(--str-text-muted, #94a3b8);
        text-align: center;
    }

    /* Bảng: ẩn cột phụ, cuộn ngang nhẹ nếu cần */
    #priceboard-tab .pb-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    #priceboard-tab .pb-table .pb-m-hide {
        display: none !important;
    }

    #priceboard-tab .pb-table {
        font-size: 12px;
        min-width: 0;
        width: 100%;
    }

    #priceboard-tab .pb-table th,
    #priceboard-tab .pb-table td {
        padding: 8px 5px;
    }

    #priceboard-tab .pb-table th.th-code,
    #priceboard-tab .pb-table td.td-code {
        position: sticky;
        left: 0;
        z-index: 4;
        min-width: 72px !important;
        max-width: 82px !important;
        width: 78px !important;
        background: var(--str-bg-surface, #121722);
        box-shadow: 4px 0 10px rgba(0, 0, 0, 0.2);
    }

    #priceboard-tab .pb-table th.th-name,
    #priceboard-tab .pb-table td.td-name {
        position: sticky;
        left: 78px;
        z-index: 3;
        min-width: 88px !important;
        max-width: 120px !important;
        width: 100px !important;
        text-align: left !important;
        overflow: hidden;
        text-overflow: ellipsis;
        background: var(--str-bg-surface, #121722);
        box-shadow: 4px 0 10px rgba(0, 0, 0, 0.12);
    }

    #priceboard-tab .pb-table thead th.th-code,
    #priceboard-tab .pb-table thead th.th-name {
        z-index: 12;
        background: var(--str-bg-surface, #141414);
    }

    #priceboard-tab .pb-table tbody tr:nth-child(even) td.td-code,
    #priceboard-tab .pb-table tbody tr:nth-child(even) td.td-name {
        background: var(--str-bg-card, #0f141c);
    }

    #priceboard-tab .pb-table tbody tr:hover td.td-code,
    #priceboard-tab .pb-table tbody tr:hover td.td-name {
        background: rgba(255, 255, 255, 0.08);
    }

    #priceboard-tab .pb-table td.td-last-price {
        font-weight: 800;
        font-size: 12.5px;
    }

    #priceboard-tab .td-actions {
        gap: 4px;
        padding: 4px 2px;
    }

    #priceboard-tab .pb-btn-action {
        min-width: 34px;
        min-height: 34px;
        padding: 6px 8px;
        font-size: 14px;
        border-radius: 8px;
        touch-action: manipulation;
    }

    /* Drawer đặt lệnh full width */
    .sps-order-drawer:not(#sps-order-drawer.inline).active {
        justify-content: stretch;
        align-items: stretch;
    }

    .sps-order-drawer:not(#sps-order-drawer.inline) .sps-drawer-content {
        width: 100% !important;
        max-width: 100% !important;
        border-left: none !important;
        padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
        padding-top: calc(12px + env(safe-area-inset-top, 0px)) !important;
    }
}

@media (max-width: 420px) {
    #priceboard-tab .pb-index-grid {
        grid-template-columns: 1fr;
    }

    #priceboard-tab .pb-table th.th-name,
    #priceboard-tab .pb-table td.td-name {
        max-width: 96px !important;
        width: 92px !important;
        left: 78px;
    }
}
